3 Replies Latest reply on Mar 16, 2004 1:15 PM by andylawson

    classcastexecption at javax.xml.parsers.DocumentBuilderFacto

    andylawson Newbie

      Hi All,

      I've spent the last few hours (or is it days) trawling through the red looking for a solution to my problem. I've added jboss-app.xml etc. etc. and nothing seems to work.

      Let me explain the problem. Hopefully somebody out there can give me a hand.

      I have an ear file, composed of an EJB, and a WAR. In the META-INF directory of the EAR I have the following files:

      application.xml
      ------------------

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">

      <display-name>xmap</display-name>

      MessageRegister.jar



      <web-uri>xmap.war</web-uri>
      <context-root>xmap</context-root>




      jboss-app.xml
      -----------------
      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-app>
      <loader-repository>xmap.com:loader=xmap.ear<loader-respository-config>java2ParentDelegation=false</loader-respository-config></loader-repository>
      </jboss-app>

      MANIFEST.MF
      ---------------
      Manifest-Version: 1.0


      My WAR file contains a load of classes in the META-INF/lib directory including, amongst others, xalan.jar, xerces.jar & xml-apis.jar. I also added a file jboss-web.xml after reading it might be useful:

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web>
      <loader-repository>xmap.com:loader=xmap.war</loader-repository>
      </jboss-web>


      I create the EAR and deploy it in JBoss (v.3.2.3) on Windows 2000 Server, and I get the following error (there´s a lot of text, I know ....)

      20:17:27,445 ERROR [Engine] StandardContext[/xmap]: Servlet /xmap threw load() exception
      javax.servlet.ServletException: XmapContext could not be instantiated.
      at com.dmr.xmap.common.manager.XmapManagerServlet.init(XmapManagerServlet.java:85)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3422)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3623)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:821)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
      at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.createWebContext(EmbeddedTomcatService.jav
      at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.performDeploy(EmbeddedTomcatService.java:3
      at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:428)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:824)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeplo
      at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentSca
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
      at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy5.deploy(Unknown Source)
      at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
      at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
      at org.jboss.Main.boot(Main.java:150)
      at org.jboss.Main$1.run(Main.java:395)
      at java.lang.Thread.run(Thread.java:534)
      20:17:27,455 ERROR [Engine] ----- Root Cause -----
      com.dmr.xmap.common.exception.XmapInstantiationException: No exception description defined.

      at com.dmr.xmap.common.context.XmapContext.(XmapContext.java:89)
      at com.dmr.xmap.common.context.XmapContext.getInstance(XmapContext.java:116)
      at com.dmr.xmap.common.manager.XmapManagerServlet.init(XmapManagerServlet.java:83)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3422)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3623)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:821)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
      at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.createWebContext(EmbeddedTomcatService.jav
      at org.jboss.web.tomcat.tc4.EmbeddedTomcatService.performDeploy(EmbeddedTomcatService.java:3
      at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:428)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:824)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeplo
      at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentSca
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
      at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy5.deploy(Unknown Source)
      at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
      at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
      at org.jboss.Main.boot(Main.java:150)
      at org.jboss.Main$1.run(Main.java:395)
      at java.lang.Thread.run(Thread.java:534)
      Caused by: com.dmr.xmap.common.exception.XmapConfigurationException: No exception description define

      at com.dmr.xmap.common.manager.XmapConfigManager.loadXmapContext(XmapConfigManager.java:52)
      at com.dmr.xmap.common.context.XmapContext.(XmapContext.java:85)
      ... 61 more
      Caused by: java.lang.ClassCastException
      at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
      at com.dmr.xmap.common.manager.XmapConfigManager.loadXmapContext(XmapConfigManager.java:34)



      I'm pretty sure that is a class loader sort-of problem, and more or less related to xalan, xerces etc. I had a look at the DocumentBuilderFactory class but didn't really work out what was going on. After reading other posts in this forum I modified the run.bat file to include lines:

      set JAXP=-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
      set JAXP=%JAXP% -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
      set JAXP=%JAXP% -Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl
      set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME% %JAXP%


      Thinking that maybe the DocumentBuilderFactory couldn't find the implementation. Alas, no good.

      I'm pretty much at my wits end with this. Has anybody out there got any ideas. Maybe I've done something stupid (wouldn't be the first time), or I need to configure something else?

      Any suggestions etc. would be most appreciated.
      Thanks,
      Andy.


        • 1. Re: classcastexecption at javax.xml.parsers.DocumentBuilderF
          Dan Durkin Newbie

          Andy,

          I'm having the same type of problem.

          As soon as I define a loader-repository of an ear deployment, I get ClassCastExceptions for xml related classes. In my case its a SAXParser class but it seems like the same deal.

          Have you made any headway on this?

          Does anyone have any suggestions for tracking down the problem?

          Can code that is loading somehow side step the scoped ClassLoader? In my case it seems like JDOM threw the original exception.

          Anyone have tips for narrowing the search.

          • 2. Re: classcastexecption at javax.xml.parsers.DocumentBuilderF
            andylawson Newbie

            Hi All,

            Managed to make some head way with this.

            I copied the files xalan.jar & xerces.jar to the jboss-3.2.3/lib directory.
            I then changed the run.bat file to add these two files to the variable JBOSS_CLASSPATH.
            I then updated my EAR (specifically the WAR) and removed the 2 files from the WEB-INF/lib directory (and some MANIFEST.MF that had these files in the ClassPath.)

            When I restarted the server the original problem disappeared. Now I have another error:

            loader constraints violated when linking org/xml/sax/InputSource class

            Not sure what is happening. If anybody can shed some light on this, it would be most appreciated.

            Andy.

            • 3. Re: classcastexecption at javax.xml.parsers.DocumentBuilderF
              andylawson Newbie

              Still pulling my hair out over this ...

              After looking through various jars, I found the offending org.xml.SAX.InputSource class in the JDK jre/lib/rt.jar. So I reckon that somehow the JDK class is helping to cause the loader violation.

              I nosed about on the internet and found out that you can override the rt.jar file by adding the appropriate jars to the jre/lib/endorsed directory. So I copied the xalan.jar, xerces.jar here, restarted JBoss and lo and behold ... the same error!!!

              Am I doing something stupid here? Has anybody got any ideas?