I am running grails 3.2.1 and want to create Swagger-documentation for my REST endpoints. I added the SwaggyDoc-plugin to the dependencies in my build.gradle script by adding:
compile "org.grails.plugins:swaggydoc-grails3:0.28.0"
And configure it by https://rahulsom.github.io/swaggydoc/ .
In IntelliJ I see the Swaggydoc-dependency added to my list of libraries.
After starting my Grails-application via the grails run-app command and opening my application by entering http://localhost:8080/api/ I get an swagger-ui index.html, but I find error in console log(see in image).
console log errors
And this exceptions in grails.
ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[grailsDispatcherServlet] - Servlet.service() for servlet [grailsDispatcherServlet] in context with path [] threw exception
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[Digest Input Stream] MD5 Message Digest from SUN
Answer
When we create grails application inside intellij we will get the following dependency inside application.yaml file.
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.11.6"
We need to replace this with the following :
runtime "org.grails.plugins:asset-pipeline"
This error will be resolved.
Related
Latest version of STS (e.g. 3.7.3) does not support Grails anymore so I'm using STS Gradle projects as workaround in order to run my Grails applications with "Spring Boot App" option. It's working just fine, but I have faced the issue below:
Issue:
Somehow all the beans declared under resources.groovy file have been ignored when I execute the application via STS running as "Spring Boot App". Notice that running the application via console "run-app" command it works fine.
Exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'facebookAuthRedirectFilter': Cannot resolve reference to bean 'redirectFailureHandlerExample' while setting bean property 'authenticationFailureHandler'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'redirectFailureHandlerExample' is defined
My resources.groovy file
package spring
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
beans = {
redirectFailureHandlerFacebook(SimpleUrlAuthenticationFailureHandler) {
setDefaultFailureUrl('/login/auth')
}
}
STS:
Version: 3.7.3.RELEASE
Build Id: 201602250940
Platform: Eclipse Mars.2 (4.5.2)
Grails:
Grails Version: 3.1.1
Groovy Version: 2.4.5
JVM Version: 1.7.0_75
It seems classpath issue but I could not find how to resolve this yet.
Issue resolved by updating Groovy compiler settings. Go to Window->Preferences->Groovy->Compiler, see below:
Doing this resources.groovy will be compiled and the beans will be available on run time.
Please note: Although I'm using the Grails Shiro plugin I believe this to be a core Grails problem, having nothing to do with the plugin whatsoever.
Mac (Yosemtie) and Grails 2.4.5 here. Here's the top 2 lines from my Config.groovy:
String configFileAbsPath = System.getProperty('configFileAbsPath')
grails.config.locations = [ "file:${configFileAbsPath}" ]
So to run locally I do something like:
grails -DconfigFileAbsPath=/Users/myuser/tmp/myapp.properties run-app
When I run this exact invocation, my app starts up and behaves just fine.
However, in non-local environments I want my config file to live under /opt/myapp/myapp.properties. So on my local machine I create a /opt/myapp directory, and then ran chmod -R 777 /opt/myapp. I then copy myapp.properties to it and run:
grails -DconfigFileAbsPath=/opt/myapp/myapp.properties run-app
This produces the following stack trace:
| Error Error generating web.xml file (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
groovy.lang.MissingPropertyException: No such property: shiro for class: java.lang.String
at ShiroGrailsPlugin$_closure4_closure30_closure34.doCall(ShiroGrailsPlugin.groovy:248)
at ShiroGrailsPlugin$_closure4_closure30_closure34.doCall(ShiroGrailsPlugin.groovy)
at ShiroGrailsPlugin$_closure4_closure30.doCall(ShiroGrailsPlugin.groovy:243)
at ShiroGrailsPlugin$_closure4_closure30.doCall(ShiroGrailsPlugin.groovy)
at ShiroGrailsPlugin$_closure4.doCall(ShiroGrailsPlugin.groovy:242)
I seriously doubt that the location of an external config file, or the file permissions set on the config file (or its parent dir) would break the Grails Shiro plugin. I think this is just a misleading Grails/Groovy exception. Most likely some kind of security exception is causing something to not load/populate correctly (and fail silently), and then when Grails Shiro kicks in during run-app, its missing something that should be there and is causing run-app to die.
Any ideas as to what is going on, or what the fix is?
Update: Running grails clean, grails clean-all and/or grails refresh-dependencies prior to invoking grails run-app do not help/solve this error either.
I generally prefer to have .groovy file for external config rather than .properties because I can write printlns into it to check whether the file is loaded or not.
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 am working on grails application and using grails 2.3.3 version. When I run grails app-run, it works fine, but for grails war, it throws Error WAR packaging error: startup failed with details following:
/home/vieenay/.grails/2.3.3/projects/VProcureFinal/gspcompile/gsp_VProcureFinal_layoutsspringSecurityUI_gsp.groovy: 2: unable to resolve class org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
# line 2, column 1.
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
^
/home/vieenay/.grails/2.3.3/projects/VProcureFinal/gspcompile/gsp_VProcureFinal_layoutsspringSecurityUI_gsp.groovy: 3: unable to resolve class grails.plugins.springsecurity.SecurityConfigType
# line 3, column 1.
import grails.plugins.springsecurity.SecurityConfigType
^
Note: I have added following plugins to buildconfig.groovy file to deploy on heroku.
compile(':heroku:1.0.1') {
exclude 'database-session'
}
compile ':cloud-support:1.0.8'
Basically I am trying to deploy my grails app to Heroku. I can run my application locally successfully but even grails war does not work and throwing above error. I tried to search grails mailing list and stackoverflow but could not get solution.
Any idea why this is happening.Please let me know you need more code to be pasted.
If you're seeing "grails.plugins.springsecurity" anywhere when using the 2.0 plugin, something's wrong. From the error, it looks like you're still using the old version of the spring-security-ui plugin - make sure you're using 1.0-RC1 of the UI plugin, and that any of the other spring-security-core secondary plugins (e.g. LDAP, ACL, etc.) are also the newer versions that are compatible with the 2.0 core plugin.
I am working on a grails app and have been trying to deploy it to glassfish . However, during deployment I get the following error:
From server logs:
[#|2013-04-16T07:53:21.540-0400|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=91;_ThreadName=Thread-1;|2013-04-16 07:53:21,540 [admin-thread-pool-7720(2)] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is **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.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
……
On my system classpath I have the following files:
slf4j-api-1.5.6.jar, slf4j-api-1.5.6.jar, slf4j-log4j12-1.5.6.jar.
I believe the problem is that Grails is trying to load the method from slf4j 1.6 (I am on Grails 2.1.0). I want Grails to use its the webapps classpath rather than using system classpath.
How do I do this ?
If I'm not mistaken you cannot have two versions of the same library in your container, so you need to upgrade the version that's in your classpath to 1.6