Grails deployment to Glassfish and slf4j - grails

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

Related

Swaggydoc Plugin grails 3.2.1

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.

Grails file resources.groovy ignored by Spring Tool Suite

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.

Exception when calling grails run-script: Error creating bean with name 'grailsApplication'

After making changes in my grails application, if I try to call 'run-script' I get the following exception:
Error org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication'
...
The extended exception will vary, depending on what changes you've made to the application.
This is occurring on grails version 2.3.1.
It turns out that 'run-script' (at least in version 2.3.1 of Grails) does not run 'compile' before it tries to run!
So, the solution is:
grails compile
grails run-script myScript.groovy

cast error with addCallbackParam in primefaces

Using the requestContext demo example in my system
http://www.primefaces.org/showcase-labs/ui/requestContext.jsf
I am getting the following error
Caused by: java.lang.ClassCastException: org.primefaces.context.DefaultRequestContext cannot be cast to org.primefaces.context.RequestContext
at org.primefaces.context.RequestContext.getCurrentInstance(RequestContext.java:38) [primefaces-3.4.1.jar:]
the error occur when the java command running
RequestContext context = RequestContext.getCurrentInstance();
Using primefaces-3.4.1 under jboss seam 2.3.0.Final with Jboss AS 7.1
Amir
You've multiple different versioned PrimeFaces JAR files in your webapp's runtime classpath. For example, one PrimeFaces 3.3 and another PrimeFaces 3.4.1. They're conflicting with each other.
Cleanup the webapp's runtime classpath so that only the most recent version remains and this problem should disappear. Paths which are by default covered by the webapp's runtime classpath are the webapp's own /WEB-INF/lib folder, server's and/or JRE's own /lib and /lib/ext folders.
Update: another, actually more rare, cause is that you've multiple PrimeFaces JAR files of the same version which are loaded by different classloaders. The getClass() on the both classes would then never match the == check. You'd need to remove one of both.

VMWare initialization error during grails run-app

When I type grails run-app to run grails application the cmd gives me this error
C:\Users\Mamun\Desktop\web\racetrack>grails run-app
Error opening zip file or JAR manifest missing : C:/Program
Error occurred during initialization of VM
agent library failed to init: instrument
C:\Users\Mamun\Desktop\web\racetrack>grails -version
Grails version: 2.0.4
But my grails working perfectly.Need help
Found this while doing a search of grails issues on GitHub. Maybe it can help you.

Resources