Grails 3.2.0 Interceptors are not working - interceptor

When i am migrating my project from grails-2.4.4 to grails-3.2.0.
Configration :
Java 8
Grails 3.2.0
Gradle 3.1.
I am also migrating filters to interceptors.
Here is my interceptor :
class MemoryUsageInterceptor {
MemoryUsageInterceptor() {
println(">>> MemoryUsageInterceptor constructor")
matchAll()
}
boolean before() {
println(">>> MemoryUsageInterceptor before")
true
}
boolean after() { true }
void afterView() {
// no-op
}
}
When my application is up then interceptor constructor is called. But its action is not called.
Can you please tell me where i am wrong.

I encountered what I believe is the same or a very similar issue. My interceptors were working when running in interactive development mode, but when I packaged them as a WAR and ran them the interceptor would not load at all.
It appears this issue was present in Grails 3.2.0 to 3.2.2.
I resolved this issue by upgrading to Grails 3.2.3.

Related

ABP Framework can't acces virtual files in Deploy

I'm working with the ABP Framework and I'm implementing my own mail templates.
The project was made using the abp project template. I created the template in my Application module: Acme.Bookstore.Application/Assets/Templates/MyEmailTemplate.tpl. I edited the properties of the file to be embedded.
Then I made an instance of the template definition provider as follows:
public class MyEmailTemplateDefinitionProvider : TemplateDefinitionProvider
{
public override void Define(ITemplateDefinitionContext context)
{
context.Add(
new TemplateDefinition(
MyEmailTemplates.MyEmailTemplate,
displayName: LocalizableString.Create<AccountResource>($"TextTemplate:{MyEmailTemplates.MyEmailTemplate}"),
layout: StandardEmailTemplates.Layout,
localizationResource: typeof(AccountResource)
).WithVirtualFilePath($"Assets/Templates/MyEmailTemplate.tpl", true)
);
}
}
Then I added the following lines to my BookstoreApplicationModule.cs
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<BookstoreApplicationModule>("Acme.Bookstore");
});
I did all this following this documentation: https://docs.abp.io/en/abp/5.3/Virtual-File-System
When debugging locally all works well, but when I deploy the project it can't access the template file. The error is as follows:
Volo.Abp.AbpException: Could not find a file/folder at the location: Assets/Templates/MyEmailTemplate.tpl
I already tried adding the AddEbedded call in the HttpApi.Host module but got the same result. I don't know what I'm missing.
For the record, I'm deploying in an Ubuntu server, but that shouldn't matter.
The problem was that the embedded files weren't being added to the VirtualFileSystem. It worked in develpment because the framework calls:
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
... Some code ...
options.FileSets.ReplaceEmbeddedByPhysical<BookstoreApplicationModule>(
Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}Acme.Bookstore.Application"));
});
}
So the problem didn't arise until I did a dotnet publish.
I could not figure out why it wasn't working on the Application module but moving the files to the Domain.Shared module fixed it.
I guess that there is some package or setting missing on the other module but this solution is enough for me.

Class constructor UpgradeComponent cannot be invoked without 'new' after Update to Angular 10

I just started to upgrade an Angular project from 9.1.0 to 10.0.12
It is still a hybrid app and has couple of components upgraded (from Angular JS) as described in the Angular docs
However after the Update to Angular 10 those upgraded components would not load and result in the following error
Class constructor UpgradeComponent cannot be invoked without 'new' (at new MyUpgradedComponentDirective)
I searched the Changelog and didn't found any information regarding UpgradeComponent.
Changing jit to true might be not the best solution - that will switch the directive to the mode, when it's compiled in browser runtime, instead of being served as pre-compiled JS code.
It seems like the issue described here might be solved with setting tsconfig.json output property to ES2015 if you have older version there.
More details can be found here: https://github.com/angular/angular-cli/issues/18067
After endless search without results I went to trial & error mode.
I discovered that there is a jit property on the #Directive, if set to true the mentioned error goes away.
With adding jit: true the upgraded component code looks something like this
#Directive({
selector: 'my-angular-selector',
jit: true,
})
export class MyDirective extends UpgradeComponent {
constructor(elementRef: ElementRef, injector: Injector) {
super('angularJsDirectiveSelector', elementRef, injector);
}
}

Google App Engine with Firebase - can't add dependencies

I'm trying to connect a backend module in Android Studio to Firebase using the tutorial here - https://cloud.google.com/solutions/mobile/firebase-app-engine-android-studio#adding_dependencies_to_the_backend_module
I cannot add the dependencies for some reason. I can't find them on the list. If I try to add them manually, I get a Gradle sync error.
For the main app module, Firebase is connected and it's functioning correctly. I set this up using Android Studio's build in Firebase tool. I've tried using this tool again but it's made no difference.
Here's my build.gradle for the backend:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.google.appengine:appengine-api-1.0-sdk'
compile 'com.google.firebase:firebase-server-sdk'
compile 'org.apache.httpcomponents:httpclient'
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
}
Here's the error I get if I add the dependencies manually, as shown in the code above:
Click here
You're probably getting errors on these dependencies. They don't have versions specified:
compile 'com.google.appengine:appengine-api-1.0-sdk'
compile 'com.google.firebase:firebase-server-sdk'
compile 'org.apache.httpcomponents:httpclient'
Every maven dependency requires a group id, artifact id, and a version string.
Also, the "firebase-server-sdk" dependency doesn't make sense to me. Access to firebase backend services is now done through the Admin SDK.
My guess is that the tutorial you linked to is simply very much out of date, and you can no longer follow it exactly, but maybe you can still learn something from it otherwise.

"cannot find symbol method setBatchPath(String)" in the generated source from generated endpoint

For an unknown reason, when I tried to build my Google App Engine endpoints, I get these errors in all of the API java files generated by Android Studio:
Error:(400, 5) error: method does not override or implement a method from a supertype
Error:(402, 29) error: cannot find symbol method setBatchPath(String)
I did some initial troubleshooting and found out that there's a Builder class inside the java file and it extends AbstractGoogleJsonClient.Builder. I looked at the source for the Builder class and I cannot find the method.
Why all of the sudden am I getting these errors? Help!
Same thing happened to me this morning.
I resolved it by adding this in my backend project
appengine {
endpoints {
googleClientVersion = '1.23.0'
}
}
and updating this version in my app gradle file.
implementation('com.google.api-client:google-api-client-android:1.23.0')
Faced the same problem. I upgraded google client libs to 1.23.0 and it worked (earlier was 1.22.0)
compile 'com.google.api-client:google-api-client:1.23.0'
compile 'com.google.http-client:google-http-client-android:1.23.0'
We already had these in our backend build.gradle:
dependencies {
compile 'com.google.api-client:google-api-client:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.http-client:google-http-client:+'
compile 'com.google.http-client:google-http-client-android:+'
}
All we needed was adding:
appengine {
endpoints {
googleClientVersion = '1.23.0'
}
}
But it'd have been nice if Google didn't break our codes every once in awhile out of the blue and wasting hours of development time!

FUBAR after update to GAE-java-sdk-1.6.0/1.6.1 persistencemanager singleton

After I updated from GAE-JAVA-SDK-1.5.5 to 1.6.0 and 1.6.1 my app stop functioning properly. it started giving an error on the RPC service.
Exception while dispatching incoming RPC call com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract void com.skip.school.client.service.AdminService.addStudent(com.skip.school.shared.Student)' threw an unexpected exception: java.lang.NoClassDefFoundError: Could not initialize class com.skip.school.server.PmfSingleton
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.skip.school.server.PmfSingleton
The whole log can be found here pastebin.
I have a singleton that should be initialized when the user starts there first rpc call.
The singleton I use should be correct there are many example found here on stackeroverflow and everywhere on the web.
public final class PmfSingleton {
private final static PersistenceManagerFactory pmfInstance = JDOHelper.getPersistenceManagerFactory("transactions-optional");
private PmfSingleton() { }
public static PersistenceManagerFactory get() {
return pmfInstance;
}
}
I call that class in all my server implementations like so.
PersistenceManager pm = PmfSingleton.get().getPersistenceManager();
this works on sdk 1.5.5 and below but not on sdk 1.6.0 and above, does anyone know what I' doing wrong what i should change if i want to use sdk 1.6.0 and above?
I read somewhere else that this problem is related to an out dated version of the datanucelus jars. I've updated to the latest version, v1.6.1 available from the eclipse plugin and I fixed it by deleting all old references to the old jars, leaving behind just these 3:
datanucleus-appengine-1.0.10.final.jar
datanucleus-core-1.1.5.jar
datanucleus-jpa-1.1.5.jar
I hope that works for you!
I had this same problem after upgrading to a newer version of AppEngine SDK. It turns out the problem was I had an older version of the appengine-api-1.0-sdk jar hanging around in the deployment folder.
Have a look in the war\WEB-INF\lib folder of your application and see if there are two different versions of appengine-api-1.0-sdk-1.x.y.jar. I fixed it by removing the appengine-api-1.0-sdk-1.5.x file.

Resources