Grails error initializing application: null - grails

When I try to run "grails run-app", I get the error and small stacktrace:
context.GrailsContextLoaderListener Error initializing the application: null
java.lang.NullPointerException
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
I'm using Grails 2.5.0 and Java 1.8.0_51.
How can I get more information about what's going wrong?
edit: I've tried grails clean and grails refresh-dependencies in all related projects.

I think this is related to reloading or recompilation. Could you retry booting after a grails clean

Our app consists of two projects. Project 1 has all the Bootstrap files and Project 2 all the domain/view/controller files. The branch I was on for Project 1 had a bootstrap file which used a domain object that was on a different branch of Project 2, so I commented out the bootstrap file. As it turns out, this is what was causing the error. To fix it, I had to DELETE the bootstrap file to get the app to run.
I guess Grails doesn't like it when there's a Bootstrap file with no code in it..

Related

Getting java.lang.NoClassDefFoundError: javax/el/ELResolver while running struts junit

I am writing junits for struts action class and using org.apache.struts2.StrutsTestCase, while running the test cases I am getting below exception.
java.lang.NoClassDefFoundError: javax/el/ELResolver
at org.apache.struts2.tiles.StrutsTilesInitializer.createContainerFactory(StrutsTilesInitializer.java:58)
at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:123)
at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:62)
at com.dmainc.agora.action.test.SetupStrutsTestCase.setUp(SetupStrutsTestCase.java:261)
so I added el-api.jar in the run config , then again ran the test, but started getting another exception i.e
java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
at org.apache.tiles.el.JspExpressionFactoryFactory.getExpressionFactory(JspExpressionFactoryFactory.java:61)
at org.apache.struts2.tiles.StrutsTilesContainerFactory.createELEvaluator(StrutsTilesContainerFactory.java:251)
at org.apache.struts2.tiles.StrutsTilesContainerFactory.createAttributeEvaluatorFactory(StrutsTilesContainerFactory.java:198)
at org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:106)
at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:124)
at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:62)
I guess this is happening due to some jar/jar version has conflict, but could not figure out why?
Any suggestions will be highly appreciated.
Solution 1:
Inner of the apache-tomcat-x.x.xx\lib folder
el-api.jar file set classpath environment variable.
Solution 2:
copy apache-tomcat-x.x.xx\lib\el-api.jar file in to jreX.X.X_XXX\lib\ext\ folder.
because it is used to preload tomcat server start
Run again your test case.

"Error occurred running Grails CLI: null" when running grails 3.0 command line

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.

Grails App fails to deploy to Heroku?

I have developed a Grails application and have deployed it many times to Heroku without an issue. However just recently I have changed the solution to use plugins from within a folder I have called "plugins". I have then basically added the following code to the BuildConfig in order to include those plugins in the application:
grails.plugin.location.'spring-security-ui'="plugins/grails-spring-security-ui"
Now when I run the delpoy to Heroku I get the following error:
|Generating plugin.xml for inline plugin
Error |
Error executing script War: java.lang.NullPointerException: Cannot get property 'file' on null object (Use --stacktrace to see the full trace)
! Failed to build app
! Heroku push rejected, failed to compile Grails app
I think this is due to the new plugins I have added to the solution via the new method. Can anyone tell me if I am missing something or what is wrong??
Also I have tested this locally and runs fine :-S
Thanks
EDIT 1......
I have tried to build the WAR file locally i got the following:
Building WAR file.....
| Error Exception occurred trigger event [CreateWarStart]: /home/admin/workspace/APP_NAME/grails-app/migrations does not exist. (Use --stacktrace to see the full trace)
| Done creating WAR target/APP_NAME-0.1.war
Try grails war locally to see if you can reproduce the problem.
This might possibly be related to GRAILS-9006 which was fixed in 2.0.4.
From trying multiple different things I have found that Heroku is rubbish at handling local plugins within Grails. So I moved over to Jelastic and runs like a dream :-)
Thanks for the help!!

Grails: server crashes when I recompile a file (when using datasources)

I'm using datasources in my Grails project.
When I edit a groovy file with server running I get the following error:
Running Grails application.. java.lang.IllegalArgumentException: Must
supply a resource type for JNDI configuration
How can I configure grails.naming.entries in Config.groovy to fix this?
Note: I'm using grails 1.3.6
Tks
I'm using 1.3.7 and hit the same issue. There's a couple bugs in the JIRA about this, looks like they were finally fixed in 2.0-M1. There's a patch for 1.3.1+ versions here, but I haven't tested that yet.
Link to possible patch: http://jira.grails.org/browse/GRAILS-7021

SpringSource Tool Suite problem

I installed STS 2.6.1.SR1 + added groovy & grails extensions. The Grails installation is pointing to Grails1.4 (Preferences->Grails). However, I can not perform any grails-related actions, like creating a new project. After importing an existing grails project (which was created in command prompt), it even can not be compiled. An output is always the same:
java.lang.NoClassDefFoundError: org/codehaus/groovy/tools/RootLoader
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.tools.RootLoader
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Exception in thread "main"
Have anyone faced something similar?
Alex.
1.4 was only released a few days ago and its structure is quite different from previous releases. STS doesn't support it yet but this is being worked on and it will soon.
Option 1 -> Upgrade STS
SpringSource Tool Suite 2.7.0.M2 has now been released and supports Grails 1.4. Release notes are here
Option 2 -> Workaround.
Full details are available on the Spring Source Issue Tracker but this workaround may help...
com.springsource.sts.grails.core.internal.model.DefaultGrailsInstall.getBootstrapClasspath doesn't look for groovy-all-x.jar in the location where Grails 1.4 keeps it.
Workaround for running Grails 1.4 apps in STS:
cd /opt/grails-1.4.0.BUILD-SNAPSHOT/lib
ln -s org.codehaus.groovy/groovy-all/jars/groovy-all-1.8.0.jar
It's not an elegant solution but FWIW, with a similar issue (wanting groovy 1.8 in grails 1.3.7) I've found in practice that swapping the grails-1.3.7/lib/groovy-all-1.7.8.jar with groovy-all-1.8.4.jar works -- except you have to call the 1.8.4 jar "groovy-all-1.7.8.jar".
Worked for my app (for dev/test until newer grails is available) but of course YMMV.

Resources