I've followed this tutorial successfully and works good on localhost. It's about using the using the grails rendering plugin. It works good and all on LOCALHOST, but when I deploy the app, or even just run grails run-war, the rendering plugin no longer works. It's giving some weird error. :(
I'm using grails 2.0.0 with rendering plugin 0.4.3 and this is what my BuildConfig.groovy contains:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
runtime ":resources:1.1.5"
compile ":rendering:0.4.3"
build ":tomcat:$grailsVersion"
}
The error is this:
2012-09-27 17:08:47,714 [http-8643-1] ERROR errors.GrailsExceptionResolver - ClassNotFoundException occurred when processing request: [GET] /profile/renderFormPDF/1
org.springframework.mock.web.MockHttpServletRequest. Stacktrace follows:
java.lang.ClassNotFoundException: org.springframework.mock.web.MockHttpServletRequest
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at grails.plugin.rendering.document.RenderEnvironment.init(RenderEnvironment.groovy:33)
at grails.plugin.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:69)
at grails.plugin.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:61)
at grails.plugin.rendering.document.XhtmlDocumentService.generateXhtml(XhtmlDocumentService.groovy:68)
at grails.plugin.rendering.document.XhtmlDocumentService.createDocument(XhtmlDocumentService.groovy:38)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:34)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:33)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:63)
at com.icodeya.ProfileController.renderFormPDF(ProfileController.groovy:108)
at net.stax.appserver.webapp.RequestMonitorValve.invoke(RequestMonitorValve.java:35)
at net.stax.appserver.admin.StaxApplicationQueryValve.invoke(StaxApplicationQueryValve.java:49)
at net.stax.appserver.webapp.RequestSetupValve.invoke(RequestSetupValve.java:31)
at java.lang.Thread.run(Thread.java:662)
That's in the spring-test jar which is in the dev environment but isn't included in the WAR file. Add
runtime 'org.springframework:spring-test:3.1.0.RELEASE'
to the dependencies section of BuildConfig.groovy.
Related
I am migrating grails-2.4.0 from 2.3.2 and jdk-1.8 from 1.7.
I am using this article for migration.
BuildConfig.groovy
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
runtime 'org.springframework:spring-test:3.1.0.RELEASE'
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.52.1"
// Default plugins for the compile step
compile ":scaffolding:2.1.0"
compile ':cache:1.1.3'
// Persistency plugins
runtime ":hibernate:3.6.10.14"
// Styling plugins
runtime ':twitter-bootstrap:3.3.4'
runtime ":resources:1.2.14"
runtime ":jquery:1.11.0.2"
// PDF rendering plugins
compile ":rendering:1.0.0"
// Spring security plugins
compile ":spring-security-core:2.0-RC5"
// Uncomment these (or add new ones) to enable additional resources capabilities
runtime ":zipped-resources:1.0.1"
runtime ":cached-resources:1.1"
compile ":cache-headers:1.1.7"
}
Removed grailsResourceLoader from applicationContext.xml
Removed sitemesh filter details from web.xml
When I run the application using grails run-app it is working fine. But when I use update,Sort etc at that time below errors are occur.
Stacktrace
ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /wba-web/airline/index - parameters:
mode:
modeId:
Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Error executing tag <sitemesh:captureContent>: Error executing tag <g:render>: null
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:189)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62)
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)
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <sitemesh:captureContent>: Error executing tag <g:render>: null
at airline_index$_run_closure10.doCall(index:26)
at airline_index.run(index:57)
... 8 more
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <g:render>: null
at airline_index$_run_closure10_closure16.doCall(index:25)
... 10 more
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
at grails.util.CacheEntry.getValue(CacheEntry.java:141)
at grails.util.CacheEntry.getValue(CacheEntry.java:81)
... 11 more
Does I miss something to upgrade? or this is bug in my code?
Quick help will highly appreciate.!!!
Please find log here log.txt.
Based on the stacktrace the error is you are passing null value to the render function, when you are hitting /wba-web/airline/index. please copy the full stacktrace for more information.
The latest version of Java have issues with Grails. However 1.8.0_25, 1.8.0_31 versions support 2.4.0. Those above 1.8.0_40 might have issues.
Actually this was the error regarding filter. Every time filter block my request. I made some changes in my custom filter and it works.!
I created and ran a grails 3.0.1 app at work, but am unable to run it on my personal computer. I followed the same method of installation for grails 3.0.1 (via gvm). The problem seems to be with gradle as grails create-app worked fine. I am also able to compile the application with gradle assemble, but cannot run the application. I am using gradle 2.3.
The complete error looks as follows:
Error Error initializing classpath: No subject alternative DNS name matching services.gradle.org found.
java.security.cert.CertificateException: No subject alternative DNS name matching services.gradle.org found.
at sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:191)
at sun.security.util.HostnameChecker.match(HostnameChecker.java:93)
at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:347)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:203)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1428)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:209)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:901)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:837)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1023)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.tooling.internal.consumer.DistributionFactory$ProgressReportingDownload.download(DistributionFactory.java:177)
at org.gradle.wrapper.Install$1.call(Install.java:59)
at org.gradle.wrapper.Install$1.call(Install.java:46)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:46)
at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:122)
at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:116)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
gradle/wrapper/gradle-wrapper.properties Change this:
-from: distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip
-to: distributionUrl=http://services.gradle.org/distributions/gradle-2.3-all.zip
It seems that https://services.gradle.org/'s certificate is messed up
As a temporary workaround you can download the gradle wrapper via http instead of https. For this you have to modify your grails wrapper configuration. I edited build.gradle
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
distributionUrl = 'http://services.gradle.org/distributions/gradle-2.3-bin.zip'
}
Then generated it by issuing the command: gradle wrapper
After this grails run-app should work.
I have grails 2.0.4 application with rendering plugin 0.44. It works fine in dev environment, however, fails in production with IncompatibleClassChangeError.
Looked into the jars to see if there are any duplicates or incompatibilities, couldn't trace anything suspicious.
Tried with clean war (grails clean, war) but didn't help.
Both production and development test are running similar setup except java minor versions - java 1.6.0_65 (dev test/mac os) and java 1.6.0_30 (production/cent os).
Any help much appreciated, thanks!
Here is my BuildConfig.groovy:
plugins{
------
compile ":qrcode:0.3"
compile ":rendering:0.4.4"
}
Here is the stack trace:
org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [our function] of controller [com.x.ourcontroller] caused exception: Runtime error executing action
at org.grails.jaxrs.web.JaxrsFilter.doFilterInternal(JaxrsFilter.java:46)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
at java.lang.Thread.run(Thread.java:701)
Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action
... 7 more
Caused by: java.lang.reflect.InvocationTargetException
... 7 more
Caused by: java.lang.IncompatibleClassChangeError
at grails.plugin.rendering.document.RenderEnvironment.init(RenderEnvironment.groovy:37)
at grails.plugin.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:75)
at grails.plugin.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:67)
at grails.plugin.rendering.document.XhtmlDocumentService.generateXhtml(XhtmlDocumentService.groovy:64)
at grails.plugin.rendering.document.XhtmlDocumentService.createDocument(XhtmlDocumentService.groovy:34)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:36)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:35)
at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:65)
at RenderingGrailsPlugin$_closure3.doCall(RenderingGrailsPlugin.groovy:59)
at com.xx.yy..
... 7 more
2014-03-19 20:55:52,025 [TP-Processor16] ERROR servlet.GrailsDispatcherServlet - HandlerInterceptor.afterCompletion threw exception
java.lang.IncompatibleClassChangeError
at org.grails.jaxrs.web.JaxrsFilter.doFilterInternal(JaxrsFilter.java:46)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
at java.lang.Thread.run(Thread.java:701)
2014-03-19 20:55:52,026 [TP-Processor16] ERROR servlet.GrailsDispatcherServlet - HandlerInterceptor.afterCompletion threw exception
java.lang.IncompatibleClassChangeError
at org.grails.jaxrs.web.JaxrsFilter.doFilterInternal(JaxrsFilter.java:46)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891) at java.lang.Thread.run(Thread.java:701)
java.lang.IncompatibleClassChangeError was happening due to a conflict between classes across different plugins with respect to MockHttpServletRequest and MockHttpServletResponse classes coming for jax-rs plugin. Tried the latest jax-rs plugin (0.9 for 2.0.x grails) which mentions in release notes that these are removed. However, this version of plugin didn't fix the problem. Manually removed the mock directory under jax-rs plugin from the war and repackaging it as a workaround for now. Removing the mock/* files fixed the problem.
I'm using the Grails AWS Plugin: https://github.com/grails-aws/grails-aws on Grails 2.2.2. I can't get the basic S3 File upload to work. I receive the error below:
Error Log:
ERROR (SLF4JBridgeHandler.java:225) - Servlet.service() for servlet [default] in context with path [] threw exception [org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/apache/http/params/SyncBasicHttpParams] with root cause
java.lang.ClassNotFoundException: org.apache.http.params.SyncBasicHttpParams
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.jets3t.service.utils.RestUtils.createDefaultHttpParams(RestUtils.java:574)
at org.jets3t.service.utils.RestUtils.initHttpConnection(RestUtils.java:298)
at org.jets3t.service.impl.rest.httpclient.RestStorageService.initHttpConnection(RestStorageService.java:209)
at org.jets3t.service.impl.rest.httpclient.RestStorageService.initializeDefaults(RestStorageService.java:166)
at org.jets3t.service.StorageService.<init>(StorageService.java:125)
at org.jets3t.service.impl.rest.httpclient.RestStorageService.<init>(RestStorageService.java:153)
at org.jets3t.service.S3Service.<init>(S3Service.java:91)
at org.jets3t.service.impl.rest.httpclient.RestS3Service.<init>(RestS3Service.java:157)
at org.jets3t.service.impl.rest.httpclient.RestS3Service.<init>(RestS3Service.java:131)
at org.jets3t.service.impl.rest.httpclient.RestS3Service.<init>(RestS3Service.java:109)
at grails.plugin.aws.s3.S3FileUpload.inputStreamUpload(S3FileUpload.groovy:85)
at grails.plugin.aws.util.MetaClassInjector$_injectS3UploadMethods_closure3.doCall(MetaClassInjector.groovy:46)
Here is the BuildConfig:
compile ":aws:1.6.7.5"
Controller:
file.inputStream.s3upload(newFilename) {
path "pictures/"
}
So there's nothing special going on here, just basic configuration, but it doesn't work. Any ideas?
UDPATE:
Ran the dependency report to make sure the app is using HTTPClient 4.2 and it is:
httpclient by org.apache.httpcomponents 4.2 4.1.2
Thanks
The the Grails AWS plugin uses AWS SDK 1.6.7 which is dependent on Apache HttpClient 4.2 as you can tell from Maven.
Please add the following dependency to your BuildConfig.groovy:
runtime 'org.apache.httpcomponents:httpclient:4.2'
I was finally able to get it to work by adding the following to the BuildConfig.groovy:
build 'org.apache.httpcomponents:httpcore:4.2'
build 'org.apache.httpcomponents:httpclient:4.2'
runtime 'org.apache.httpcomponents:httpcore:4.2'
runtime 'org.apache.httpcomponents:httpclient:4.2'
I have a strange situation in a grails application. My application use spring-security-ui, and I'm using the class org.codehaus.groovy.grails.plugins.springsecurity.ui.RegistrationCode.
The weird stuff is that, when I use this class the application throw an Exception:
java.lang.NoClassDefFoundError: org.codehaus.groovy.grails.plugins.springsecurity.ui.RegistrationCode
but If I try to open the grails shell and write a script that import that class, it works.
If I generate the war and deploy it on Tomcat the application works fine.
It is just the run-app that won't work.
Which can be the cause of this error?
Thanks
UPDATE:
Now I have the same situation when I try to register a user, or do a login...
2012-07-10 12:24:40,835 ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - NoClassDefFoundError occurred when processing request: [GET] /myapplication/dashboard
org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils.
Stacktrace follows:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'LoginController': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [LoginController]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:909)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [LoginController]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
... 3 more
Caused by: java.lang.NoClassDefFoundError: org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
... 3 more
But if I put this piece of code in a controller it works:
println org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils.class
Some suggest?
MORE INFO:
Plug-ins you currently have installed are listed below:
-------------------------------------------------------------
blueprint 1.0.2 -- Blueprint CSS framework
burning-image 0.6.0 -- Burning Image
ckeditor 3.6.2.1 -- CKeditor plugin
constraints 0.6.0 -- Custom domain constraints plugin
famfamfam 1.0.1 -- Silk icons from famfamfam.com
hibernate 2.0.1 -- Hibernate for Grails
invoicer 0.1 -- Invoicer Plugin
jdbc-pool 0.3 -- Tomcat JDBC Pool plugin
jquery 1.7.1 -- JQuery for Grails
jquery-ui 1.8.15 -- jQuery UI resources
jquery-validation 1.7.3 -- JQuery Validation Plugin
jquery-validation-ui1.2.3 -- JQuery Validation UI Plugin - Client Side Validation without writing JavaScript
lesscss-resources 1.3.0.3 -- Less CSS Resources
mail 1.0 -- Provides Mail support to a running Grails application
quartz 0.4.2 -- This plugin adds Quartz job scheduling features to Grails application.
rendering 0.4.3 -- Grails Rendering
resources 1.1.6 -- Resources
spring-security-core1.2.7.2 -- Spring Security Core Plugin
spring-security-ui 0.2 -- Spring Security UI
tomcat 2.0.1 -- Apache Tomcat plugin for Grails
webxml 1.4.1 -- WebXmlConfig
I have the classes to manage spring security users, roles and controllers in a plugin developed from another company.
But it is strange because the NoClassDefFoundError is for SpringSecurityUtils class, that if I try to import it inside a controller it works fine...
The problem is that the library is not included in your development environment:
You can add the library to your development environment simply by adding the dependency in the BuildConfig.groovy file :
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
runtime 'mysql:mysql-connector-java:5.1.20'
runtime 'apacheexec:commons-exec:1.1' // this is the external library that I added which is the apache commons exec.
}
for more info go to this page :
http://grails.org/doc/latest/guide/conf.html#configurationsAndDependencies
I hope it helps