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.
Related
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.
I have just moved to the new Grails 3.1, and my first app in Grails worked fine. But when I created a another new Grails 3.1 app I ran into a new problem; the problem occurs when try to run using run-app interactively in the new application root:
| Running application...
Error: Could not find or load main class try3grails.Application
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
| Error Failed to start server (Use --stacktrace to see the full trace)
The class try3grails.Application referers to the first app's main method class I created; so the error seems to be that Grails cannot 'forget' the old app classpath. Does any one have a solution to this or is there something I missed?
Running grails --version gives:
| Grails Version: 3.1.4
| Groovy Version: 2.4.6
| JVM Version: 1.8.0_77
Grails is installed using SDKMan on a ubuntu linux machine.
Make sure you are running run-app from the right directory.
Also try to do some cleaning:
grails clean could help.
If nothing helps - you can clear grails/gradle cache, or create a new app.
I believe I have found "workaround" by updating the gradle wrapper version from 2.9 to 2.12(or 2.10 works too).
This is done by updating the version number in gradle.properties
and in gradle/wrapper/gradle-wrapper.properties, and then executing:
./gradlew wrapper
I'm trying to run grails list-profiles, but receive the following error:
snowch#snowch-ws2:~/repos$ grails list-profiles --stacktrace
| Error Error occurred running Grails CLI: null (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NullPointerException
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.main(GrailsCli.groovy:99)
| Error Error occurred running Grails CLI: null
My versions are:
snowch#snowch-ws2:~/repos$ grails --version
| Grails Version: 3.0.1
| Groovy Version: 2.4.3
| JVM Version: 1.7.0_75
This was on a fresh install of grails and gvm.
The command grails create-app myapp works without error.
This question is similar to Grails 3.0 error, nullpointer, however, that question does not state what command is being run.
After searching online, I found that I needed to set my GRAILS_OPTS environment variable as follows before running the command:
export GRAILS_OPTS="-XX:-UseSplitVerifier -Xverify:none"
Source of fix: https://grails.org/news/1292028
I have not figured out, what is the exact cause of the error, but it seems to occur if you try to run grails 3 in the system where grails 2 is also installed.
What I did to get the command run - I created the project in a new directory. The directory for my old grails app was:
/home/me/projects/oldgrailsapp
when I tried to execute the grails command in /home/me/projects it failed, but when I tried this in another directory /home/me/projects_new, it succeeded. So I guess that the problem was that old grails configuration was somehow interfering with the new one.
I also removed references to old grails and groovy versions from the PATH variable by editing .bashrc file in my home directory (I really do not know if it was needed).
I had same experience when I was working on "Building an Andoird Client" guide, I got the following message whenever I try to create an app in the same folder where I've created the first app grails-app :
| Error Error occurred running Grails CLI: null (Use --stacktrace to see the ful
l trace)
So obviously, when you create a grails app in folder containing "grails-app" directory, grails will consider this folder as full grails application, hence cannot create-app in that directory.
I used:
Grails 3.1.15
Java 1.8.0.101
Hope this help.
It worked for me now.
this was my setting
GRAILS_HOME=C:\Users\murali.solayappan\apps\grails-3.1.11
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_102
I received the same error while launching "grails" for the first time
**Error occurred running Grails CLI: connect timed out**
After reading GRAILS_HOME\bin\grails.bat i found that executing "grails" while in GRAILS_HOME dir makes some difference. So I did the same
Now i received error stating that GRAILS couldn't find a particular maven package from my mirror repository - printed my private nexus repository url. I know that's my private repo and not connected to internet.
so I changed the MY_HOME_DIR.m2\"settings.xml" with the one came by default in Maven.
After that executed "grails" while in %GRAILS_HOME% dir.
It worked like breeze !!! I got grails prompt.
C:\Users\murali.solayappan\apps>grails
| Enter a command name to run. Use TAB for completion:
grails> exit
Somethimes it happens when you have wrong version of grails installed for the project you want to run it on
try to run it somewhere else and see if you get the same error
i had the same issue because i was using Grails 1.3.5 witj Java 8 which are incompatibles. I changed with Java 7 and it works fine.
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.
When trying to start a project (./grailsw run-app) for the first time with the latest version of the database-migration plugin, it fails with the following error:
Error Compilation error: startup failed:
[..]/work/plugins/database-migration-1.3.8/src/groovy/grails/plugin/databasemigration/GormDatabaseSnapshotGenerator.groovy: 48: You cannot create an instance from the abstract class 'liquibase.snapshot.DatabaseSnapshot'.
# line 48, column 31.
DatabaseSnapshot snapshot = new DatabaseSnapshot(db, requestedSchema)
I'm using java7 on OSX:
$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
This seems vaguely familiar to me; I was able to find random references to other projects in 2009-2011 about this. Nothing current; and nothing found in the specific plugin's issue tracker. I'd ask there but I expect this is a fairly standard issue, not related to the specific grails plugin.
A peer is using java6. I went back to java6 (apple(tm) version), ran ./gradlew --refresh-dependencies run-app and got the same thing.
Looks like liquibase made that class abstract in v3
However, the plugin looks like it should be using v2.0.5
So as far as I can see, for v2.0.5 it should be ok?
Unless you've added a dependency to liquibase v3?