Grails 2,运行战争 -> java.lang.ClassNotFoundException:grails.test.mixin.services.ServiceUnitTestMixin

发布于 2024-12-22 16:11:45 字数 1387 浏览 0 评论 0原文

有了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

演出会有结束 2024-12-29 16:11:45

我遇到了类似的问题,并通过按顺序执行以下操作解决了它:

  1. 删除目标目录中的所有内容
  2. grails clean
  3. grailscompile
  4. grails run-war

I encountered a similar issue and solved it by doing the following in order:

  1. Delete everything in the target directory
  2. grails clean
  3. grails compile
  4. grails run-war
巷子口的你 2024-12-29 16:11:45

我遇到了完全相同的问题,并且接受的答案对我不起作用,所以我更仔细地研究了...

我发现的是一个类 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 of grails-app/test/unit/ into grails-app/services/; probably during some kind of package rename refactoring. After moving MyServiceTests back to test/unit everything has worked fine again.

久隐师 2024-12-29 16:11:45

控制器的包名称必须与域类的包名称匹配。确保您的包名称在整个项目中保持一致,包括包名称的小写和大写。有些 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.

高速公鹿 2024-12-29 16:11:45

我和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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文