0

我创建了一个 JasperReport 应用程序,它在 tomcat 服务器上运行良好。但是当我使用同一个 jar 在 Jboss 上运行时,它会显示错误

    at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2]
at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2]
at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112) [:0.2.2]
at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87) [:0.2.2]
at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91) [:0.2.2]
at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132) [:6.1.0.Final]
at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.1.0.Final]
at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-6]
at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-6]
at java.lang.Thread.run(Thread.java:745) [:1.7.0_75]

引起:java.lang.ClassCastException:org.apache.xerces.jaxp.DocumentBuilderFactoryImpl 无法在 javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source) [:1.7.0_75] 处转换为 javax.xml.parsers.DocumentBuilderFactory org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:854) [:] at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778) [:] at org.apache.log4j。 helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526) [:6.1.0.Final] at org.apache.log4j.LogManager.(LogManager.java:127) [:6.1.0.Final]

4

1 回答 1

0

问题是 Jboss 在 Jboss lib 中包含类“org.apache.xerces.jaxp.DocumentBuilderFactoryImpl” ,而在应用程序 war 文件的 lib 文件夹中包含相同的类“javax.xml.parsers.DocumentBuilderFactory” 。所以这两个类都会发生冲突。这就是发生类转换异常的原因。

要解决此问题,请从应用程序 war 文件的 lib 文件夹中删除包含类“javax.xml.parsers.DocumentBuilderFactory”的 jar 文件。xml-apis-1.3.02.jar文件中包含的类“javax.xml.parsers.DocumentBuilderFactory” 。

所以从war文件中删除xml-apis-1.3.02.jar 。可以通过在 maven 的“pom.xml”文件中排除它来完成

于 2016-06-24T09:12:55.903 回答