Grails 4: Micronaut fails with NoClassDefFoundError: javax/annotation/PreDestroy - grails

I migrated a Grails 3.3.10 application to Grails 4.0.0, moving from Java 8 to OpenJDK 11. After some work to make the tests and application run on my development environment ( a windows 10 machine ), I packaged my executable war in a docker adoptopenjdk/openjdk11:alpine. The docker's entrypoint just runs the app:
java <some options> -jar /app/application.war
The docker when run however gives an error when initializing Micronaut:
java.util.ServiceConfigurationError: Error loading service
[org.grails.databinding.converters.$DefaultConvertersConfigurationDefinitionClass]:
javax/annotation/PreDestroy
at io.micronaut.core.io.service.DefaultServiceDefinition.lambda$load$0(DefaultServiceDefinition.java:71)
...
Caused by: java.lang.NoClassDefFoundError: javax/annotation/PreDestroy
...
Caused by: java.lang.ClassNotFoundException: javax.annotation.PreDestroy
I tried to add compile 'javax.annotation:javax.annotation-api:1.3.2' in my gradle dependencies, without success.
What's missing to make my application run?

Java 11 no longer ships with some of the javax libraries.
Following the instruction from https://blog.codefx.org/java/java-11-migration-guide/#Migrating-From-Java-8-To-Java-11 solved the issue.

Related

Error running Grails 3 application on CMD

I am new to Grails and never made any project on it. I followed some tutorials and downloaded both Grails and JDK and set my environment variables exactly as specified, but when I tried to run the application, I got this error and my application is not running:
Error initializing classpath: could not determine java version from '10.0.2'
I just used CMD and none of the IDE is used, please help me solve this problem.
First check classpath of both for Java & Grails by running these command java -version & grails -version
If you found problem in classpath then solve by this way http://grails.asia/grails-tutorial-for-beginners-setup-your-windows-development-environment/
Although its better to use Java 8, not Java 10

Grails 3.0 error, nullpointer

I was just trying to run Grails 3.0.1 in commandline via "grails" but it failed with the following stacktrace:
| Error Error occurred running Grails CLI: null
java.lang.NullPointerException
at org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(DefaultGroovyMethods.java:3137)
at org.grails.cli.profile.git.GitProfileRepository.getAllProfiles(GitProfileRepository.groovy:72)
at org.grails.cli.profile.commands.ListProfilesCommand.handle(ListProfilesCommand.groovy:43)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:173)
at org.grails.cli.GrailsCli.getBaseUsage(GrailsCli.groovy:118)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:162)
at org.grails.cli.GrailsCli.main(GrailsCli.groovy:99)
| Error Error occurred running Grails CLI: null
I'm using this version of Java
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
I have tried all the things mentioned in different threads, including setting GRAILS_OPTS. The issue seems to go away after running
grails create-app myApp and create a sample app.
Not sure why, but seems like a connection problem with the Grails repo, which resolved after running the command.

Grails: GGTS not running on Amazon AWS EC2 anyone else successful?

I'm just curious if anyone has had success trying to run the Groovy Grails tool suite on an Amazon AWS EC2 instance with its display exported into your windows machine. If so, I wanted to know which flavor of linux was used on the EC2. I am not having much success with it on the Amazon Linux but haven't tried their Ubuntu instances yet. I got all the way to getting GGTS installed and getting the display exported but when I launch GGTS I get log errors about libraries missing. This is most likely because I didn't use yum to install it so I am probably missing dependencies but I didn't have a choice its not offered as a yum package. Here are my log file errors when I try to launch GGTS:
!SESSION 2014-06-08 03:08:04.873 -----------------------------------------------
eclipse.buildId=3.5.1.201405030657-RELEASE-e43
java.version=1.7.0_55
java.vendor=Oracle Corporation
Framework arguments: -product org.springsource.ggts.ide
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.springsourc
e.ggts.ide
!ENTRY org.eclipse.osgi 4 0 2014-06-08 03:08:12.116
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
/home/ec2-user/ggts_sh/ggts-3.5.1.RELEASE/configuration/org.eclipse.osgi
/bundles/704/1/.cp/libswt-pi-gtk-4335.so: libgtk-x11-2.0.so.0: cannot open share
d object file: No such file or directory
no swt-pi-gtk in java.library.path
/home/ec2-user/.swt/lib/linux/x86_64/libswt-pi-gtk-4335.so: libgtk-x11-2
.0.so.0: cannot open shared object file: No such file or directory
Can't load library: /home/ec2-user/.swt/lib/linux/x86_64/libswt-pi-gtk.s
o
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:331)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240)
at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:45)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:133)
at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:679)
at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:162)
at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(
IDEApplication.java:154)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEAppli
cation.java:96)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandl
e.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runAppli
cation(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Ec
lipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja
va:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja
va:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Run GGTS using Ec2 Ubuntu instead. All needed packages are there without the dependency headache. I have been successful in getting GGTS running in Ec2 Ubuntu with display exported onto my Windows environment.
The issue here is similar to : facing trouble launching spoon.sh on amazon ec2 linux
You are missing the following libraries: libswt-gtk-3-jni libswt-gtk-3-java. Either you have to recompile them (and all transitive dependencies like GTK), or use another image like Ubuntu from which you can simply do a apt-get install libswt-gtk-3-jni libswt-gtk-3-java.

Grails org.slf4j.spi.LocationAwareLogger.log not found

I'm using Grails 2.3.8
I've created a default app using
grails create-app testapp
When I run:
grails runApp
I get the following issue:
| Configuring classpath
| Error Error executing script RunApp: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.eclipse.aether.internal.impl.Slf4jLoggerFactory$Slf4jLoggerEx.debug(Slf4jLoggerFactory.java:163)
at org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider.newLocalRepositoryManager(DefaultLocalRepositoryProvider.java:142)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.newLocalRepositoryManager(DefaultRepositorySystem.java:421)
at grails.util.BuildSettings.doResolve(BuildSettings.groovy:513)
at grails.util.BuildSettings.doResolve(BuildSettings.groovy)
at grails.util.BuildSettings$_getDefaultBuildDependencies_closure17.doCall(BuildSettings.groovy:774)
at grails.util.BuildSettings$_getDefaultBuildDependencies_closure17.doCall(BuildSettings.groovy)
at grails.util.BuildSettings.getDefaultBuildDependencies(BuildSettings.groovy:768)
at grails.util.BuildSettings.getBuildDependencies(BuildSettings.groovy:673)
| Error Error executing script RunApp: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
I tried running:
grails dependency-report
but I get the same issue.
java -version
gives:
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Not sure if this is your problem, but I vaguely recall there being some problems with Groovy and the earlier versions of Java 7. I'd recommend moving to the most recent. I have no problems with 2.3.8 and jdk1.7.0_55 (most recent at time of writing).
Have you looked for conflicting versions of slf4j? Try running Grails dependency-report.
There are a few other SO questions that indicate this to be a cause of issue. Eg: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log
sl4j error in weblogic when deploying grails application war
One thing that can help in debugging situations like this is doing:
export JAVA_OPTS="-verbose"
You can then see which slf4j JAR is being loaded by the JVM, but yes there is undoutably some conflicing slf4j JAR on your classpath
There was an instance of slf4j in:
/Library/Java/Extensions/
Moving that out seems to have fixed the problem.

Can't get Grails application to run on Windows 7

I'm having trouble running Grails on my PC (running Windows 7).
It's been a couple of years since I last worked with Grails, and I have a new computer. So I downloaded Grails and NetBeans and followed the instructions. (Grails: version 2.3.7, NetBeans: version 7.4.)
Everything seems to be working. Both the Java JDK and Grails work - I can run "grails" from the command prompt. And it was easy to activate the support for Grails in NetBeans.
I created a very simple "Hello world" application. It compiles fine - and I can run "grails war" to create a War file. But I can't get it to run on my PC. I get the same error using "Run" in NetBeans and when running "grails run-app" at the command prompt:
|Running Grails application
Error opening zip file or JAR manifest missing : C:\Program%20Files\Grails
\lib\org.springframework\springloaded\jars\springloaded-1.1.5.RELEASE.jar
Error occurred during initialization of VM
agent library failed to init: instrument
Error |
Forked Grails VM exited with error
And the program won't start. The jar in question isn't missing, so I can't see what's wrong. Any ideas? I'd be more than grateful for some help! :-)
/Anders from Sweden
Move your copy of grails to C:\ and try again.
There is a known problem with location with space symbol. You can see it in stacktrace:
C:\Program%20Files\...

Resources