我在grails应用程序中有一个奇怪的情况。我的应用程序使用security,我使用的是org.codehaus.groovy.grails.plugins.springsecurity.ui.RegistrationCode.类
奇怪的是,当我使用这个类时,应用程序抛出一个异常:
java.lang.NoClassDefFoundError: org.codehaus.groovy.grails.plugins.springsecurity.ui.RegistrationCode但是,如果我试图打开grails 并编写一个导入该类的脚本,它就能工作。如果我生成war并将其部署到Tomcat上,则应用程序可以正常工作。只是运行应用程序不起作用。哪个可能是造成这个错误的原因?
谢谢
更新:
现在,当我尝试注册一个用户或者登录时,我也遇到了同样的情况.
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但是如果我把这段代码放在控制器中,它就能工作了:
println org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils.class有人建议?
更多信息:
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在另一家公司开发的插件中,我有管理spring安全用户、角色和控制器的类。但是奇怪的是,因为NoClassDefFoundError是针对SpringSecurityUtils类的,如果我试图在控制器中导入它,它就能正常工作.
发布于 2014-01-04 21:37:44
问题是您的开发环境中没有包含库:只需在BuildConfig.groovy文件中添加依赖项,就可以将库添加到开发环境中:
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.
}有关更多信息,请访问以下页面:http://grails.org/doc/latest/guide/conf.html#configurationsAndDependencies
我希望它能帮上忙
https://stackoverflow.com/questions/10704539
复制相似问题