ItGo.me Focus on IT Recommend

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

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

I would like use Primefaces and Myfaces on my application. However there is an exception.

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$000(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$1.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]

How is this caused and how can I solve it?

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

jsf primefaces web.xml myfaces
|
  this question
edited Jul 21 '15 at 8:44 asked Jul 17 '15 at 8:59 PhiHDN 93 1 1 11 1   Please put the exception message into a code block to make it more readable. –  Tiny Jul 17 '15 at 9:06      thanks for your suggestion. edited –  PhiHDN Jul 21 '15 at 8:45      please post the relevant code/configuration as well. –  chsdk Jul 21 '15 at 8:51

 | 

1 Answers
1

---Accepted---Accepted---Accepted---

Your webapp's runtime classpath is polluted with multiple different versioned JAXP libraries. In your specific case, the mentioned classes are loaded by different classloaders (one via server itself and other via webapp itself) and therefore couldn't be cast to each other.

Simply cleanup and remove the duplicate JAXP-related libraries in classpath (such as Xalan in your specific case). This covers among others the webapp's /WEB-INF/lib folder and server's /lib folder. Do note that the average server already ships with JAXP out the box. So you do not need to provide those along your webapp at all.

Recommend:xml - CXF java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to com.tibco.ur.schemas.getocr.Output

--Created by TIBCO WSDL--><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.tibco.com/UR/schemas/GenericWS" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="Untitled" targetNamespace="h

This is not a JSF specific problem.


|
  this answer
answered Jul 17 '15 at 9:06 BalusC 715k 228 2632 2820      Thank you for your answer. I removed xalan.jar from war file. However, this issue is still there. :( Did I miss something? –  PhiHDN Jul 21 '15 at 8:46      Then there are more or the build is still dirty. –  BalusC Jul 21 '15 at 8:50      I also tried to remove xalan.jar from server's lib (inside modules folder in Jboss 7) but it caused java.lang.NoClassDefFoundError: org/apache/xpath/XPathAPI –  PhiHDN Jul 21 '15 at 8:56      I didn't know that there is xalan.jar on <JBoss Home>/modules/system/layers/base/org/apache/xalan/main. I remove my own xalan.jar and use that one. Then the exception has been gone. Thank you very much for your help! –  PhiHDN Aug 18 '15 at 8:18 1   You shouldn't have the need to touch the server. Your webapp is the one who shouldn't need to ship with a JAXP implementation in /WEB-INF/lib. –  BalusC Aug 18 '15 at 8:19  |  show more comment

Recommend:jsf - java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory

nal I get 2 Class Cast Exceptions. I was hoping that when it worked on JBoss 7.1 I could get it going on 6.1 as they are both JEE6. Sadly I must use JBoss 6.1 as I've a dependency on JBoss ESB. Any advice appreciated... ERROR [org.apache.ca

oriUlr:http://stackoverflow.com/questions/31471980/java-lang-classcastexception-org-apache-xml-dtm-ref-dtmmanagerdefault-cannot-be

------splitte line----------------------------
阿里云RDS