Error at application bootstrap after upgrade to grails 2.3.1 - grails

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"
[...]
}

Related

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

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.

Error initializing classpath: No subject alternative DNS name matching services.gradle.org found. -> when running grails 3.0.1 app

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.

Grails-Camel Plugin won't install or run

Please note: Although this question involves a lib called Apache Camel I really think this is just a question about how modern Grails plugins work.
I am on Grails 2.4.2 here, and I am trying to use Apache Camel with Grails and found the Grails Routing plugin annd cannot even get it to install.
The directions say to install by issuing a grails install-plugin routing. When I do this I get:
grails install-plugin routing
Starting process on LT-IE-ZH/10.10.99.14
Loading Grails 2.4.2
|Configuring classpath
.
|Environment set to development
......Warning
|
Since Grails 2.3, it is no longer possible to install plugins using the install-plugin command.
Plugins must be declared in the grails-app/conf/BuildConfig.groovy file.
Example:
grails.project.dependency.resolution = {
...
plugins {
compile ":routing:1.3.2"
}
}
So I modify my BuildConfig.groovy like so:
plugins {
// plugins for the build system only
build ":tomcat:7.0.54"
compile ":routing:1.3.2"
...lots of other stuff omitted for brevity
}
Then the plugin says to create routes, issue a grails create-route <RouteName>. So I do exactly that:
grails create-route OrderListener
Starting process on LT-IE-ZH/10.10.99.14
Loading Grails 2.4.2
|Configuring classpath
|Running pre-compiled script
|Script 'CreateRoute' not found, did you mean:
1) CreateFilters
2) CreatePom
3) CreateApp_
4) CreateController
5) CreateHibernateCfgXml
Please make a selection or enter Q to quit:
What is going on here?!? How do I install/use this plugin?!? Am I losing my mind, or does this plugin simply not work?
Update
I run grails clean-all, then grails refresh-dependencies then grails create-route OrderListener and I get:
Loading Grails 2.4.2
.
|Environment set to development
.....Error
|
groovy.lang.MissingMethodException: No signature of method: CreateRoute.createArtifact() is applicable for argument types: () values: []
Error |
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Error |
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
Error |
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
Error |
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Error |
<huge stacktrace omitted>
Error |
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
Error |
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
Error |
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
Error |
... 68 more
Whenever you make a change in BuildConfig.groovy be sure to run grails compile to trigger dependency resolution, which will download new and updated plugins and jars, and it will also compile your code which helps to ensure that things are minimally compatible at least.
But the core issue here is that the plugin's CreateRoute.groovy script is badly broken. It's missing an important include and doesn't come close to calling createArtifact correctly. As a workaround until the authors get this fixed, create a script in your app's scripts folder called CreateCamelRoute.groovy with this content:
includeTargets << grailsScript('_GrailsCreateArtifacts')
target(createCamelRoute: "Creates a new Camel Route.") {
createArtifact(type: 'Route', path: 'grails-app/routes', name: argsMap.params?.get(0) ?: 'Example', suffix: 'Route')
}
setDefaultTarget(createCamelRoute)
It's intentionally named differently from the original because if Grails finds two with the same name it asks which one to use. This way you can just run
grails create-camel-route com.foo.bar.OrderListener
and it will work. Note that I changed the example a bit to include a package - always use packages :)

Grails 2.2.2 Geb 0.9.0 Spock 0.7 exception

I create a project with grails 2.2.2, add
test "org.seleniumhq.selenium:selenium-firefox-driver:2.28.0"
test "org.seleniumhq.selenium:selenium-support:2.31.0"
test "org.gebish:geb-spock:0.9.0"
test "org.gebish:geb-junit4:0.9.0"
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
in dependencies in BuildConfig.groovy and
test ":geb:0.9.0"
test(":spock:0.7") {
exclude "spock-grails-support"
}
in plugins in BuildConfig.groovy.
Then I create the functional folder in test folder (add it to classpath), create GebConfig.groovy inside with
import org.openqa.selenium.firefox.FirefoxDriver
driver = {
def driver = new FirefoxDriver()
driver
}
baseUrl = "http://localhost:8080/TestGebSpock/"
I don't create any test whatsoever, just run the test :
test-app :functional
I got this stacktrace and no information about it on the net :
Loading Grails 2.2.2
| Environment set to test.....
| Packaging Grails application.....
| Tests FAILED - view reports in /Users/Fiftoine/workspace/TestGebSpock/target/test-reports
| Error java.lang.NullPointerException
| Error at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
| Error at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
Full stacktrace here : http://pastebin.com/CKtzNJtN
Did anyone have had this error before and solved it?
Any help would be appreciated as this is quite simple to reproduce...
Thanks in advance

NoClassDefFoundError org.codehaus.groovy.grails.plugins.springsecurity.ui.RegistrationCode only with run-app

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

Resources