Search code examples
javamavenjbossseam

Dom4J IllegalAccessError - Seam on JBoss 7 deployment error


I'm migrating a legacy application to Maven (and hopefully later away from Seam). There already have been many hitches and glitches, AFAIK Seam is really fickle concerning dependency versions it will work with.

This latest error I can't figure out. So I have an EAR with my (EJB) Jar, a War and the Seam.jar, plus lib/ folder. Now I actually have Dom4J as a dependency with scope=provided, since JBoss AS 7.1 provides version 1.6.1. It gets included into lib/ anyway, which I haven't figured out why yet.

But I get the same error when deleting all superfluous jars from lib/.

Just to reiterate, this application was running before, when built with the Ant build files. The Maven produced EAR won't deploy though. I have heard about similar errors (but not the exact same) with dependencies doubled in the classpath. I have checked (after removing it from lib/) and there should be none but the one in JBoss' modules.

Update: POM structure: Super-POM is parent of all modules, has DependencyManagement and also contains modules (for now). Modules: Core-ejb has code and tons of dependencies, mostly with provided since they are in JBoss/modules. Core-web produces WAR, has dep on Core-EJB. Project-Web includes Core-Web, Project-EJB depends on Core-EJB and uses shade-plugin to merge them together (!). Core-EAR generates ear from shaded-project-ejb and project-web. (Structure is crazy, but dictated by legacy app).

12:42:37,694 INFO  [javax.servlet.ServletContextListener] (MSC service thread 1-6) Welcome to Seam 2.3.1.Final
12:42:38,745 INFO  [org.jboss.seam.init.Initialization] (MSC service thread 1-6) reading /WEB-INF/components.xml
12:42:38,749 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (MSC service thread 1-6) Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener: java.lang.IllegalAccessError: tried to access class org.dom4j.io.SAXHelper from class org.dom4j.io.SAXReader
    at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894) [dom4j-1.6.1.jar:1.6.1]
    at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715) [dom4j-1.6.1.jar:1.6.1]
    at org.dom4j.io.SAXReader.read(SAXReader.java:435) [dom4j-1.6.1.jar:1.6.1]
    at org.dom4j.io.SAXReader.read(SAXReader.java:343) [dom4j-1.6.1.jar:1.6.1]
    at org.jboss.seam.util.XML.getRootElement(XML.java:24) [jboss-seam-2.3.1.Final.jar:2.3.1.Final]
    at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:227) [jboss-seam-2.3.1.Final.jar:2.3.1.Final]
    at org.jboss.seam.init.Initialization.create(Initialization.java:133) [jboss-seam-2.3.1.Final.jar:2.3.1.Final]
    at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36) [jboss-seam-2.3.1.Final.jar:2.3.1.Final]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]

mvn dependency:tree output, after cleanin up one mistake (but same error still):

[INFO] ------------------------------------------------------------------------
[INFO] Building Core Framework 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ Core ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Core EJB module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ Core-ejb ---
[INFO] com.mycomp:Core-ejb:ejb:1.0-SNAPSHOT
[INFO] +- org.hibernate:hibernate-core:jar:4.2.0.Final:provided
[INFO] |  \- (dom4j:dom4j:jar:1.6.1:provided - omitted for duplicate)
[INFO] +- dom4j:dom4j:jar:1.6.1:provided
[INFO] \- org.jdom:jdom:jar:1.1.2:provided
[INFO]    \- jaxen:jaxen:jar:1.1.3:provided
[INFO]       \- (dom4j:dom4j:jar:1.6.1:provided - omitted for duplicate)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Core Web module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ Core-web ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project EJB module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ project-ejb ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project Web module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ project-web ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Core EAR module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ Core-ear ---
[WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution

core-ear POM:

...
<dependencies>
    <!-- project specific dependencies -->
    <dependency>
        <groupId>com.mycomp</groupId>
        <artifactId>project-web</artifactId>
        <version>${logis.artifact.version}</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>com.mycomp</groupId>
        <artifactId>project-ejb</artifactId>
        <version>${logis.artifact.version}</version>
        <type>ejb</type>
    </dependency>

    <!-- Seam dependency -->
    <dependency>
        <groupId>org.jboss.seam</groupId>
        <artifactId>jboss-seam</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <!-- Tell Maven we are using Java EE 6 -->
                <version>6</version>
                <!-- Use Java EE ear libraries as needed. Java EE ear libraries are 
                    in easy way to package any libraries needed in the ear, and automatically 
                    have any modules (EJB-JARs and WARs) use them -->
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <!-- See maven docs; Necessary because we CAN'T have 2 jboss-seam.jars 
                    in the same EAR -->
                <skinnyWars>true</skinnyWars>
                <initializeInOrder>true</initializeInOrder>
                <modules>
                    <!-- Explicitly excluding core framework artifacts, as they get merged 
                        (shaded) into the project artifacts -->
                    <ejbModule>
                        <groupId>com.mycomp</groupId>
                        <artifactId>core-ejb</artifactId>
                        <excluded>true</excluded>
                    </ejbModule>

                    <!-- <webModule>
                        <groupId>com.mycomp</groupId>
                        <artifactId>core-web</artifactId>
                        <excluded>true</excluded>
                    </webModule> -->

                    <!-- Project specific part -->
                    <ejbModule>
                        <groupId>com.mycomp</groupId>
                        <artifactId>project-ejb</artifactId>
                        <!-- Manually set jar name, because many JndiNames in logis hard-code 
                            that name -->
                        <bundleFileName>core.jar</bundleFileName>
                    </ejbModule>
                    <webModule>
                        <groupId>com.mycomp</groupId>
                        <artifactId>project-web</artifactId>
                        <contextRoot>/</contextRoot>
                    </webModule>

                    <!-- Need to include Seam as a module so it will be "executed" and 
                        can initialize itself -->
                    <jarModule>
                        <groupId>org.jboss.seam</groupId>
                        <artifactId>jboss-seam</artifactId>
                        <includeInApplicationXml>true</includeInApplicationXml>
                        <bundleDir>/</bundleDir>
                    </jarModule>
                </modules>
            </configuration>
        </plugin>
...

Solution

  • It looks like it was some conflict with multiple versions on the classpath anyway.

    There was a company specific module, which was just a bunch of jars rolled into one module. After making sure, that only one jdom-*.jar was on the path, it worked.