javamavenapache-tomeemulti-moduleopenejb

TomEE throws An invalid Lifecycle transition


I'm doing a major refactor of a web application using the maven multi-module approach. At the get-go there was only 1 module. I've slowly been breaking out functionality and creating a dependency chain that the main module would depend on.

Other pertinent information worth mentioning: We are using the following:

Currently my web-app is structured like this:

parent
  pom.xml  
     |
     common
       pom.xml
     |
     persistence
       pom.xml
     | 
     export
       pom.xml
     |
     main
       pom.xml

So... The common module's pom has NO other module dependencies.

The persistence module's pom has the following dependencies:

common

The export module's pom has the following dependencies:

common
persistence

The main module's pom has the following dependencies:

common
persistence
export

The parent module's pom specifies the REACTOR Build Order as follows:

common
persistence
export
main

Prior to the creation of the export module everything would build and deploy fine; however, now that I've broken out additional stuff from main and put it into the export module, the build is fine, but when I deploy the generated WAR file, the following stack-trace shows up upon start-up:

SEVERE: ContainerBase.removeChild: destroy:
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]] in state [STARTING_PREP]
    at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:409)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:299)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1041)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1167)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1148)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.undeployWebApps(TomcatWebAppBuilder.java:635)
    at org.apache.openejb.assembler.classic.Assembler.destroyApplication(Assembler.java:1275)
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:955)
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:537)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:982)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
    at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

Oct 05, 2016 12:51:23 PM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal
SEVERE: Unable to deploy collapsed ear in war    
StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]     org.apache.openejb.OpenEJBException: Creating application failed:
C:\java\servers\apache-tomee-jaxrs-1.5.1\webapps\act-cde: Error building bean 'TaskDataAccessServices'.  Exception: class java.lang.NoClassDefFoundError:     
Could not initialize class   com.myapp.cde.persistence.ejb.TaskDataAccessServices: Could not initialize class com.myapp.cde.persistence.ejb.TaskDataAccessServices
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:959)
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:537)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:982)
    at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
    at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

Caused by: org.apache.openejb.OpenEJBException: Error building bean 'TaskDataAccessServices'.  Exception: class java.lang.NoClassDefFoundError:  
Could not initialize class  
com.myapp.cde.persistence.ejb.TaskDataAccessServices: Could not   
initialize class  
com.myapp.cde.persistence.ejb.TaskDataAccessServices
    at    org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarBuilder.java:81)
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:713)
    ... 18 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.myapp.cde.persistence.ejb.TaskDataAccessServices
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:274)
    at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.load(EnterpriseBeanBuilder.java:425)
    at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.loadClass(EnterpriseBeanBuilder.java:405)
    at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.build(EnterpriseBeanBuilder.java:81)
    at org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarBuilder.java:66)
    ... 19 more

Notice the TaskDataAccessServices mentioned in the stack-trace. This class is located in the persistence module. What's weird is that it's NOT used at all in the export module, which I've just created.

Question of the day: What's the best approach at debugging this issue?

I've thought about backing out changes one by one and putting classes back into the main module --- but this could take awhile ...

Wondering if there was a silver bullet approach to resolving this?

Cheers.


Solution

  • In the main pom.xml file, I had the following <dependency>:

    <dependency>
       <groupId>net.sf.ehcache</groupId>
       <artifactId>ehcache</artifactId>
       <version>2.8.3</version>
    </dependency>
    

    In the export pom.xml file, I had the following <dependency>:

    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <version>1.7.21</version>
     </dependency>
    

    Little did I know that the ehcache had it's own dependency of slf4j.

    Changing the ehcache <dependency> to the following fixed things up for me:

    <dependency>
       <groupId>net.sf.ehcache</groupId>
       <artifactId>ehcache</artifactId>
       <version>2.8.3</version>
       <exclusions>
          <exclusion>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
          </exclusion>
       </exclusions>
    </dependency>
    

    Figuring this out required me to back things out one at a time until things stopped breaking.

    Lesson learned here: commit small, commit often.