简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM