Grails 2,运行战争 -> java.lang.ClassNotFoundException:grails.test.mixin.services.ServiceUnitTestMixin
有了一个 Grails 2 应用程序并执行 run-app 工作正常,但 run-war 失败:
2011-12-24 12:43:40,996 [Thread-2] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Lgrails/test/mixin/services/ServiceUnitTestMixin;
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: Lgrails/test/mixin/services/ServiceUnitTestMixin;
at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
at java.lang.Class.getDeclaredField(Class.java:1880)
... 5 more
Caused by: java.lang.ClassNotFoundException: grails.test.mixin.services.ServiceUnitTestMixin
... 7 more
在使用 Grails 2 获得几乎完美的体验后遇到这个问题,
这是怎么发生的对我来说完全是一个令人头疼的问题:
java.lang.NoClassDefFoundError: Lgrails/test/mixin/services/ServiceUnitTestMixin;
..任何反馈将不胜感激。
Got a Grails 2 app and executing run-app works fine, run-war fails:
2011-12-24 12:43:40,996 [Thread-2] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Lgrails/test/mixin/services/ServiceUnitTestMixin;
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: Lgrails/test/mixin/services/ServiceUnitTestMixin;
at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
at java.lang.Class.getDeclaredField(Class.java:1880)
... 5 more
Caused by: java.lang.ClassNotFoundException: grails.test.mixin.services.ServiceUnitTestMixin
... 7 more
Just run into this problem after having a pretty much flawless experience of working with Grails 2,
How has this come about is a complete headscratcher for me:
java.lang.NoClassDefFoundError: Lgrails/test/mixin/services/ServiceUnitTestMixin;
... any feedback will be most appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了类似的问题,并通过按顺序执行以下操作解决了它:
I encountered a similar issue and solved it by doing the following in order:
我遇到了完全相同的问题,并且接受的答案对我不起作用,所以我更仔细地研究了...
我发现的是一个类
MyServiceTests
,它以某种方式设法溜出了grails-app/test/unit/
进入grails-app/services/
;可能在某种包重命名重构期间。将MyServiceTests
移回测试/单元后,一切都再次正常工作。I had the exact same issue and the accepted answer didn't work for me, so I dived a bit closer...
What I found is a class
MyServiceTests
that had somehow managed to sneak out ofgrails-app/test/unit/
intograils-app/services/
; probably during some kind of package rename refactoring. After movingMyServiceTests
back to test/unit everything has worked fine again.控制器的包名称必须与域类的包名称匹配。确保您的包名称在整个项目中保持一致,包括包名称的小写和大写。有些 IDE 在更新整个项目中的意外拼写错误方面并不一致。
The package name of the controller has to match the package name of the domain class. Make sure your package names are consistent throughout the project, including lower and upper case in the package name. Some IDEs are not consistent in updating accidental typos throughout the project.
我和johanneslink有类似的情况。
该应用程序无法在 Tomcat 中启动。检查 catalina.out 显示由 grails.test.mixin.services.ServiceUnitTestMixin 引起的 ClassNotFoundException
我使用 grep 查找整个应用程序文件夹中所有出现的“ServiceUnitTestMixin”(从 grails-app 的父级开始)。我发现不知何故我已将 grails.test.mixin.Mock 导入到控制器中。
一旦我删除了它并清理/编译了 war 文件,它就部署并开始正常运行。
I had a similar situation to johanneslink.
The application wouldn't start in Tomcat. Checking catalina.out showed a ClassNotFoundException caused by grails.test.mixin.services.ServiceUnitTestMixin
I used grep to look for all occurrences of 'ServiceUnitTestMixin' in the whole of the application folder (starting in the parent of grails-app). I found that somehow I'd imported grails.test.mixin.Mock into a Controller.
Once I removed that and clean/compiled the war file it deployed and started just fine.