3

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?

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

Phi
  • 153
  • 2
  • 3
  • 12

3 Answers3

9

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.

This is not a JSF specific problem.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you for your answer. I removed xalan.jar from war file. However, this issue is still there. :( Did I miss something? – Phi Jul 21 '15 at 08:46
  • Then there are more or the build is still dirty. – BalusC Jul 21 '15 at 08: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 – Phi Jul 21 '15 at 08:56
  • I didn't know that there is xalan.jar on /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! – Phi Aug 18 '15 at 08: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 08:19
  • Xalan came into the classpath via one of our dependencies, putting this in the "configurations" section of our main gradle file killed it off and fixed the problem immediately: all*.exclude group: 'xalan', module: 'xalan' – Scott Bennett-McLeish Jan 28 '16 at 07:36
0

In my case, JBoss already have xalan jar file inside module folder

<JBoss>/modules/system/layers/base/org/apache/xalan/main

So i removed xalan jar file from my application lib folder and start with JBoss default one. Its started successfully.

Anand saga
  • 1,433
  • 11
  • 23
-1

When exposing web-service using Spring-WS, I got this exception. When the parameter 'transformWsdlLocations' is removed from MessageDispatcherServlet in web.xml. This issue got resolved.