Dom4J IllegalAccessError - Seam on JBoss 7 部署错误
Dom4J IllegalAccessError - Seam on JBoss 7 deployment error
我正在将遗留应用程序迁移到 Maven(并希望以后远离 Seam)。已经有很多障碍和故障,AFAIK Seam 在将要使用的依赖版本方面真的很善变。
我无法弄清楚这个最新的错误。所以我有一个 EAR 和我的 (EJB) Jar,一个 War 和 Seam.jar,加上 lib/ 文件夹。现在我实际上将 Dom4J 作为 scope=provided 的依赖项,因为 JBoss AS 7.1 提供了版本 1.6.1。无论如何它都包含在 lib/ 中,我还没有弄清楚为什么。
但是当我从 lib/ 中删除所有多余的 jar 时,我得到了同样的错误。
重申一下,此应用程序是 运行 之前使用 Ant 构建文件构建的。不过,Maven 生成的 EAR 不会部署。我听说过类似的错误(但不完全相同),类路径中的依赖项增加了一倍。我已经检查过(在从 lib/ 中删除它之后)应该有 none 但 JBoss' 模块中的那个。
更新: POM结构:
Super-POM 是所有模块的父级,具有 DependencyManagement 并且还包含模块(目前)。
模块:Core-ejb 有代码和大量依赖项,大部分是提供的,因为它们在 JBoss/modules 中。 Core-web 产生 WAR,依赖于 Core-EJB。 Project-Web 包括 Core-Web,Project-EJB 依赖于 Core-EJB 并使用 shade-plugin 将它们合并在一起(!)。
Core-EAR 从 shaded-project-ejb 和 project-web 生成 ear。
(结构很疯狂,但由遗留应用决定)。
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 输出,清理一个错误后(但仍然是同样的错误):
[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
芯耳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>
...
看起来它与类路径上的多个版本有一些冲突。
有一个公司特定的模块,它只是一堆 jar 包在一个模块中。在确保路径上只有一个 jdom-*.jar 后,它起作用了。
我正在将遗留应用程序迁移到 Maven(并希望以后远离 Seam)。已经有很多障碍和故障,AFAIK Seam 在将要使用的依赖版本方面真的很善变。
我无法弄清楚这个最新的错误。所以我有一个 EAR 和我的 (EJB) Jar,一个 War 和 Seam.jar,加上 lib/ 文件夹。现在我实际上将 Dom4J 作为 scope=provided 的依赖项,因为 JBoss AS 7.1 提供了版本 1.6.1。无论如何它都包含在 lib/ 中,我还没有弄清楚为什么。
但是当我从 lib/ 中删除所有多余的 jar 时,我得到了同样的错误。
重申一下,此应用程序是 运行 之前使用 Ant 构建文件构建的。不过,Maven 生成的 EAR 不会部署。我听说过类似的错误(但不完全相同),类路径中的依赖项增加了一倍。我已经检查过(在从 lib/ 中删除它之后)应该有 none 但 JBoss' 模块中的那个。
更新: POM结构: Super-POM 是所有模块的父级,具有 DependencyManagement 并且还包含模块(目前)。 模块:Core-ejb 有代码和大量依赖项,大部分是提供的,因为它们在 JBoss/modules 中。 Core-web 产生 WAR,依赖于 Core-EJB。 Project-Web 包括 Core-Web,Project-EJB 依赖于 Core-EJB 并使用 shade-plugin 将它们合并在一起(!)。 Core-EAR 从 shaded-project-ejb 和 project-web 生成 ear。 (结构很疯狂,但由遗留应用决定)。
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 输出,清理一个错误后(但仍然是同样的错误):
[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
芯耳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>
...
看起来它与类路径上的多个版本有一些冲突。
有一个公司特定的模块,它只是一堆 jar 包在一个模块中。在确保路径上只有一个 jdom-*.jar 后,它起作用了。