Search code examples
grailswartomcat7classnotfoundexceptiongrails-2.0

Grails 2, run-war -> java.lang.ClassNotFoundException: grails.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.


Solution

  • 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