2

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>
...
Benjamin Maurer
  • 3,602
  • 5
  • 28
  • 49
  • Is it possible to post your pom.xml. Can you issue the following command as well? mvn dependency:tree -Dverbose -Dincludes=dom4j – javapapo Jan 05 '16 at 13:34
  • Thank you for that suggestion. I've found one duplication, where hibernate wasn't set to provided.. and would also include dom4j. But I get the same error. I didn't want to post all the POMs, because it's so much texts. Not sure which one would be most relevant. Posted the EAR pom for now. – Benjamin Maurer Jan 05 '16 at 15:13
  • Hi, have you exposed the specific library as Jboss module? using the specific descriptor? . See [here](http://stackoverflow.com/questions/12624049/java-lang-runtimeexception-error-while-reading-web-inf-components-xml) for a relevant error :) . – javapapo Jan 05 '16 at 15:23
  • By the way I see you have a weird wiring in your pom, skinny war setting, but then excluding modules + shading (uber jar). Do you really have to do this? (I am just asking) – javapapo Jan 05 '16 at 15:24
  • Yes it's in my jboss-deployment-structure.xml. Wiring might be weird and I'm definitely open to suggestions. I have core-ejb as a dependency in project-ejb and I shade it. When including project-ejb in my ear, I end up having core-ejb.jar and project-ejb.jar in it (and project-ejb.jar is shaded and contains all the stuff). Which I don't understand honestly – Benjamin Maurer Jan 05 '16 at 19:38
  • Hi Ben, from what I understand, (I might be wrong) you really dont need to shade anything - you are packaging an ear anyway. So using the maven ear plugin, using your skinnywar setting should be just fine. – javapapo Jan 05 '16 at 19:40
  • Well, I know it's weird, but I have to deal with some oddities of the legacy project structure. I need to shade because there are some config files in project-ejb.jar which are also needed for core-ejb.jar... But even if I disable the plugin, I get the same error. Seam isn't playing nice with some library for some reason, but I can't figure it out... – Benjamin Maurer Jan 11 '16 at 08:26

1 Answers1

0

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.

Benjamin Maurer
  • 3,602
  • 5
  • 28
  • 49