Jenkins grails error java.lang.ClassNotFoundException: geb.transform.AttributeAccessingMetaClassRegisteringTransformation - grails

I trying to run geb and spock tests on Jenkins with grails 2.3.4 but I get error
Error |
Error executing script TestApp: startup failed:
Could not instantiate global transform class
geb.transform.AttributeAccessingMetaClassRegisteringTransformation specified at
jar:file:/var/lib/jenkins/.m2/repository/org/gebish/geb-ast/0.12.0/geb-ast-0.12.0.jar!/
META-INF/services/org.codehaus.groovy.transform.ASTTransformation
because of exception java.lang.ClassNotFoundException:
geb.transform.AttributeAccessingMetaClassRegisteringTransformation
Could not instantiate global transform class
geb.transform.implicitassertions.ImplicitAssertionsTransformation specified at
jar:file:/var/lib/jenkins/.m2/repository/org/gebish/geb-implicit-assertions/0.12.0/
geb-implicit-assertions-0.12.0.jar!/META-INF/services/org.codehaus.groovy.transform.
ASTTransformation because of exception java.lang.ClassNotFoundException:
geb.transform.implicitassertions.ImplicitAssertionsTransformation

How I figure out my Jenkins was using java 6 and grails 2.3.4. When I update java version from 6 to 7 and grails from 2.3.4 to 2.4.5 version all was worked correctly.

Related

Grails 3.1.10 exclude spring-boot-starter-tomcat plugin from war generation

If I leave the "spring-boot-starter-tomcat" plugin dependency set to compile in the gradle build file I get the following error messages deploying to a standalone Tomcat 7 server:
INFO: validateJarFile(/usr/share/tomcat/webapps/ROOT/WEB-INF/lib/tomcat-embed-core-8.0.36.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Aug 18, 2016 2:51:19 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/usr/share/tomcat/webapps/ROOT/WEB-INF/lib/tomcat-embed-el-8.0.36.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
If I change the dependency to provided I can deploy to Tomcat but get the following error attempting to run or debug within IntelliJ IDEA 15:
ERROR org.springframework.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [orderserver.Application]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
...
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
...
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
...
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
How can I exclude these dependencies from the war file generation while retaining the ability to run/debug within IDEA?
Even better is there a way to generate a single war file that has embedded Tomcat for standalone execution that can also be deployed to a Tomcat container?
This issue was resolved by changing the dependency to provided and using a "Grails" run/debug configuration instead of the "Application" configuration that was set when I created the project with IDEA 15.

IncompatibleClassChangeError with grails rendering plugin 0.44

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.

ClassNotFoundException when running Grails AWS Plugin

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'

Error at application bootstrap after upgrade to grails 2.3.1

After upgrading my grails app from grails 2.2.4 to grails 2.3.1 the test-app build fails at the application bootstrap with the following error message:
Fatal error running tests: Method on class [de.javandry.minigolf.webapp.Role] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
Running the build with --stacktrace --verbose I see the following details (stacktraces reduced to the IMHO relevant lines):
2013-10-25 22:56:27,876 [main] WARN util.DTDEntityResolver - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
2013-10-25 22:56:28,674 [main] WARN hibernate.AbstractEhcacheRegionFactory - Couldn't find a specific ehcache configuration for cache named [de.javandry.minigolf.webapp.Role]; using defaults.
2013-10-25 22:56:32,264 [main] WARN servlet.DefaultGrailsApplicationAttributes - ApplicationContext not found in org.codehaus.groovy.grails.APPLICATION_CONTEXT attribute of servlet context.
| Error 2013-10-25 22:56:34,473 [main] ERROR plugins.DefaultGrailsPluginManager - Error configuring dynamic methods for plugin [hibernate:3.6.10.M3]: org.grails.datastore.gorm.GormStaticApi.setTransactionManager(Lorg/springframework/transaction/PlatformTransactionManager;)V
java.lang.NoSuchMethodError: org.grails.datastore.gorm.GormStaticApi.setTransactionManager(Lorg/springframework/transaction/PlatformTransactionManager;)V
at org.codehaus.groovy.grails.orm.hibernate.HibernateGormStaticApi.<init>(HibernateGormStaticApi.groovy:67)
at org.codehaus.groovy.grails.orm.hibernate.HibernateGormEnhancer.getStaticApi(HibernateGormEnhancer.groovy:87)
...
at grails.plugin.hibernate3.HibernatePluginSupport$__clinit__closure3.doCall(HibernatePluginSupport.groovy:444)
...
| Error Fatal error running tests: Method on class [de.javandry.minigolf.webapp.Role] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
java.lang.IllegalStateException: Method on class [de.javandry.minigolf.webapp.Role] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
...
at de.javandry.minigolf.webapp.Role.currentGormInstanceApi(Role.groovy)
at de.javandry.minigolf.webapp.Role$currentGormInstanceApi$0.call(Unknown Source)
...
at de.javandry.minigolf.webapp.Role.save(Role.groovy)
at de.javandry.minigolf.webapp.Role$save.call(Unknown Source)
...
at BootStrap$_closure1.doCall(BootStrap.groovy:7)
My BootStrap.groovy looks as follows:
class BootStrap {
def init = { servletContext ->
def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true, failOnError: true)
def userRole = new Role(authority: 'ROLE_USER').save(flush: true, failOnError: true)
...
The error occurs at line 3 when the first entity is created.
[edit] I've already adjusted the plugins and dependencies. Here's the part of my BuildConfig.groovy:
def seleniumVersion = "2.21.0"
def gebVersion = "0.9.0"
dependencies {
test("org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion") {
exclude "xml-apis"
}
test "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
test "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
test "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
test "org.gebish:geb-spock:$gebVersion"
}
plugins {
runtime ":hibernate:3.6.10.M3"
runtime ":jquery:1.10.2"
runtime ":resources:1.2.1"
runtime ":database-migration:1.3.6"
build ":tomcat:7.0.40.1"
compile ":cache:1.1.1"
compile ":spring-security-core:1.2.7.3"
compile ":webxml:1.4.1"
test ":geb:$gebVersion"
test ":build-test-data:2.0.6"
}
What else can I try to fix this error?
Grails 2.3.1 requires Hibernate 3.6.10.2 plugin version. This is mentioned in the release notes: http://grails.org/2.3.1%20Release%20Notes
See also
http://jira.grails.org/browse/GRAILS-10686
Update your hibernate plugin
for grails 2.3.1
plugins {
runtime ":hibernate:3.6.10.2"
[...]
}
for grails 2.3.2
plugins {
compile ":hibernate:3.6.10.3"
[...]
}

Grails Rendering Plugin gives java.lang.ClassNotFoundException when deployed

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.

Resources