java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault 无法转换为 org.apache.xml.dtm.DTMManager

java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault cannot be cast to org.apache.xml.dtm.DTMManager

我想在我的申请中使用 Primefaces 和 Myfaces。但是有一个例外。

00:31:01,292 SEVERE [org.primefaces.config.ConfigContainer] (http--0.0.0.0-8081-1) Could not load or parse web.xml: java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault cannot be cast to org.apache.xml.dtm.DTMManager
    at org.apache.xml.dtm.DTMManager.newInstance(DTMManager.java:137) [xalan.jar:4.0.2 (build: CVSTag=JBoss_4_0_2 date=200505022023)]
    at org.apache.xpath.XPathContext.<init>(XPathContext.java:102) [xalan.jar:4.0.2 (build: CVSTag=JBoss_4_0_2 date=200505022023)]
    at org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:115)
    at org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:99)
    at org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:184)
    at org.primefaces.config.ConfigContainer.initErrorPages(ConfigContainer.java:314) [primefaces-5.2.jar:5.2]
    at org.primefaces.config.ConfigContainer.initConfigFromWebXml(ConfigContainer.java:291) [primefaces-5.2.jar:5.2]
    at org.primefaces.config.ConfigContainer.<init>(ConfigContainer.java:88) [primefaces-5.2.jar:5.2]
    at org.primefaces.context.DefaultApplicationContext.<init>(DefaultApplicationContext.java:35) [primefaces-5.2.jar:5.2]
    at org.primefaces.context.DefaultRequestContext.getApplicationContext(DefaultRequestContext.java:227) [primefaces-5.2.jar:5.2]
    at org.primefaces.metadata.transformer.MetadataTransformerExecutor.processEvent(MetadataTransformerExecutor.java:50) [primefaces-5.2.jar:5.2]
    at javax.faces.event.SystemEvent.processListener(SystemEvent.java:43) [myfaces-api-2.1.12.jar:2.1.12]
    at org.apache.myfaces.application.ApplicationImpl._traverseListenerList(ApplicationImpl.java:2471) [myfaces-bundle-2.1.12.jar:2.1.12]
    at org.apache.myfaces.application.ApplicationImpl.access[=13=]0(ApplicationImpl.java:120) [myfaces-bundle-2.1.12.jar:2.1.12]
    at org.apache.myfaces.application.ApplicationImpl$SystemListenerEntry.publish(ApplicationImpl.java:2662) [myfaces-bundle-2.1.12.jar:2.1.12]
    at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:601) [myfaces-bundle-2.1.12.jar:2.1.12]
    at javax.faces.component.UIComponentBase._publishPostAddToViewEvent(UIComponentBase.java:235) [myfaces-api-2.1.12.jar:2.1.12]
    at javax.faces.component.UIComponentBase.setParent(UIComponentBase.java:215) [myfaces-api-2.1.12.jar:2.1.12]
    at javax.faces.component._ComponentFacetMap.setNewParent(_ComponentFacetMap.java:178) [myfaces-api-2.1.12.jar:2.1.12]
    at javax.faces.component._ComponentFacetMap.put(_ComponentFacetMap.java:145) [myfaces-api-2.1.12.jar:2.1.12]
    at javax.faces.component._ComponentFacetMap.put(_ComponentFacetMap.java:33) [myfaces-api-2.1.12.jar:2.1.12]
    at javax.faces.component.UIViewRoot._getComponentResources(UIViewRoot.java:623) [myfaces-api-2.1.12.jar:2.1.12]
    at javax.faces.component.UIViewRoot.addComponentResource(UIViewRoot.java:157) [myfaces-api-2.1.12.jar:2.1.12]
    at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.processEvent(ResourceViewHandlerWrapper.java:95) [tomahawk20-1.1.14.jar:1.1.14]
    at javax.faces.event.SystemEvent.processListener(SystemEvent.java:43) [myfaces-api-2.1.12.jar:2.1.12]
    at org.apache.myfaces.application.ApplicationImpl._traverseListenerListWithCopy(ApplicationImpl.java:2517) [myfaces-bundle-2.1.12.jar:2.1.12]
    at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:594) [myfaces-bundle-2.1.12.jar:2.1.12]
    at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:616) [myfaces-bundle-2.1.12.jar:2.1.12]
    at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:222) [myfaces-bundle-2.1.12.jar:2.1.12]
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170) [myfaces-bundle-2.1.12.jar:2.1.12]
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) [myfaces-bundle-2.1.12.jar:2.1.12]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197) [myfaces-api-2.1.12.jar:2.1.12]
    at com.esilicon.web.jsf.FacesServletDecorator.service(FacesServletDecorator.java:62) [:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:294) [tomahawk20-1.1.14.jar:1.1.14]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at com.esilicon.web.ResponseHeaderFilter.doFilter(ResponseHeaderFilter.java:27) [:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357) [tomahawk20-1.1.14.jar:1.1.14]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at com.esilicon.vms.web.admin.UserLoggedOffFilter.doFilter(UserLoggedOffFilter.java:40) [:]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_22]

这是怎么造成的,我该如何解决?

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

您的网络应用程序的运行时类路径被多个不同版本的 JAXP 库污染。在您的具体情况下,提到的 类 由不同的类加载器加载(一个通过服务器本身,另一个通过 webapp 本身),因此不能相互转换。

只需清理并删除类路径中重复的 JAXP 相关库(例如您的特定情况下的 Xalan)。其中包括 webapp 的 /WEB-INF/lib 文件夹和服务器的 /lib 文件夹。请注意,一般服务器已经随附了开箱即用的 JAXP。所以你根本不需要在你的网络应用程序中提供这些。

这不是 JSF 特有的问题。

当使用 Spring-WS 公开网络服务时,我遇到了这个异常。当参数'transformWsdlLocations'从web.xml中的MessageDispatcherServlet中移除时。此问题已解决。