6 Replies Latest reply on Mar 24, 2009 6:14 AM by jaikiran pai

    ClassCastException/Error instantiating servlet class org.apa

    Petter Stray Newbie

      Hi
      I am currently porting an application from WebSphere 5.1 to JBoss 4.0, but am having problems getting it deployed on JBoss. The application uses EJB's and a great deal of XML parsing, and has been working for many years already on WebSphere.

      The application is packed in an ear, with a war and several jar within it.

      When i try to deploy I get the following error:

      09:59:57,390 ERROR [Digester] Digester.getParser:
      java.lang.ClassCastException
       at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:26)
       at org.apache.commons.digester.Digester.getFactory(Digester.java:478)
       at org.apache.commons.digester.Digester.getParser(Digester.java:683)
       at org.apache.commons.digester.Digester.getXMLReader(Digester.java:891)
       at org.apache.commons.digester.Digester.parse(Digester.java:1591)
       at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java:1112)
       at org.apache.struts.action.ActionServlet.init(ActionServlet.java:324)
       at javax.servlet.GenericServlet.init(GenericServlet.java:211)
       at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
       at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
       at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
      ...
      09:59:57,406 ERROR [Engine] ----- Root Cause -----
      java.lang.NullPointerException
       at org.apache.commons.digester.Digester.getXMLReader(Digester.java:891)
       at org.apache.commons.digester.Digester.parse(Digester.java:1591)
       at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java:1112)
       at org.apache.struts.action.ActionServlet.init(ActionServlet.java:324)
       at javax.servlet.GenericServlet.init(GenericServlet.java:211)
       at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
       at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
       at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
       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)
      



      However, when I remove the xmlparserv2.jar from the ear, the error changes to:
      [Loaded org.jboss.management.j2ee.statistics.StatelessSessionBeanStatsImpl]
      09:51:01,359 INFO [TomcatDeployer] deploy, ctxPath=/formsolution/xmltf, warUrl=file:/C:/jboss-4.0.0/server/default/tmp/deploy/tmp5041185598026612330f
      ormsolution.ear-contents/xmltransform-exp.war/
      [Loaded org.apache.log4j.spi.AppenderAttachable]
      [Loaded org.apache.log4j.Category]
      [Loaded org.apache.log4j.Logger]
      [Loaded org.apache.catalina.authenticator.FormAuthenticator]
      [Loaded sun.reflect.GeneratedConstructorAccessor28]
      [Loaded org.apache.struts.action.ActionServlet]
      [Loaded java.lang.ClassCircularityError from C:\j2sdk1.4.2_19\jre\lib\rt.jar]
      09:51:01,468 INFO [Engine] StandardContext[/formsolution/xmltf]Marking servlet action as unavailable
      09:51:01,468 ERROR [Engine] StandardContext[/formsolution/xmltf]Servlet /formsolution/xmltf threw load() exception
      javax.servlet.ServletException: Error instantiating servlet class org.apache.struts.action.ActionServlet
       at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:996)
       at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
       at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      ....
      09:51:01,484 ERROR [Engine] ----- Root Cause -----
      java.lang.NoClassDefFoundError: org/xml/sax/SAXException
       at java.lang.Class.getDeclaredConstructors0(Native Method)
       at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
       at java.lang.Class.getConstructor0(Class.java:1930)
       at java.lang.Class.newInstance0(Class.java:278)
       at java.lang.Class.newInstance(Class.java:261)
       at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:987)
       at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
       at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      


      Does anybody have an idea on how I can fix this? I've been at it for a couple of days and starting to get a little fed up...

      -Petter

        • 2. Re: ClassCastException/Error instantiating servlet class org
          Petter Stray Newbie

          I tried that, but this only gives me a different error:

          10:51:30,468 ERROR [Engine] ----- Root Cause -----
          java.lang.LinkageError: loader constraints violated when linking org/xml/sax/InputSource class
           at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:708)
           at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:670)
           at org.apache.struts.action.ActionServlet.init(ActionServlet.java:329)
           at javax.servlet.GenericServlet.init(GenericServlet.java:211)
           at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
           at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
           at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
           at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
           at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
           at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          


          • 3. Re: ClassCastException/Error instantiating servlet class org
            jaikiran pai Master

            Could you please post the configuration files that you changed to achieve the classloader scoping? And which exact version of JBossAS do you use and which version of Java? And by the way, any specific reason for 4.0 version of AS instead of the latest stable 4.2.3 GA version in the 4.x series?

            • 4. Re: ClassCastException/Error instantiating servlet class org
              Petter Stray Newbie

              Content of jboss-web.xml within the war packed in the ear:

              <?xml version="1.0" encoding="UTF-8"?>
              <jboss-web>
               <resource-ref>
               <res-ref-name>jdbc/formsolution</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <jndi-name>java:/OracleDS</jndi-name>
               </resource-ref>
               <class-loading>
               <loader-repository>
               org.xml.sax:jar=xmlparserv2.jar
               </loader-repository>
               </class-loading>
              </jboss-web>



              jboss.xml in same war:

              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
               <enterprise-beans>
               <session>
               <ejb-ref>
               <ejb-ref-name>ejb/DataFacade</ejb-ref-name>
               <jndi-name>OracleDS</jndi-name>
               </ejb-ref>
               <resource-ref>
               <res-ref-name>jdbc/formsolution</res-ref-name>
               <jndi-name>java:/OracleDS</jndi-name><!--JNDI name-->
               </resource-ref>
               </session>
               </enterprise-beans>
               <resource-managers>
               <resource-ref>
               <res-ref-name>jdbc/OracleDS</res-ref-name>
               <res-type>javax.sql.DataSource</res-type>
               <jndi-name>java:/OracleDS</jndi-name>
               </resource-ref>
               </resource-managers>
               <jboss-web>
               <resource-ref>
               <res-ref-name>jdbc/formsolution</res-ref-name>
               <jndi-name>java:/OracleDS</jndi-name><!--JNDI name-->
               </resource-ref>
               </jboss-web>
              


              The reason I use 4.0.0 (Release ID: JBoss [Zion] 4.0.0 (build: CVSTag=JBoss_4_0_0 date=200409200418) is that the application uses java 1.4 (old app).

              • 5. Re: ClassCastException/Error instantiating servlet class org
                Petter Stray Newbie

                Hi again,
                I have now been able to work a little past this error (although I still get the nullpointer on Digester.getXMLReader during deploy). I now get a "failed to connect to iiop:1099" error message.

                Is this a known bug in version 4.0.0? When googling I have found some references to this from testers of the 4.0 alpha version...

                -Petter

                • 6. Re: ClassCastException/Error instantiating servlet class org
                  jaikiran pai Master

                   

                  "straypet" wrote:
                  I now get a "failed to connect to iiop:1099" error message.

                  Are you using iiop:1099 some place in your code or jndi.properties? For JBoss, the protocol is jnp. And the lookup usually uses jnp://localhost:1099. And please post the entire exception stacktrace.


                  "straypet" wrote:

                  The reason I use 4.0.0 (Release ID: JBoss [Zion] 4.0.0 (build: CVSTag=JBoss_4_0_0 date=200409200418) is that the application uses java 1.4 (old app).


                  Petter, i would recommend that you use JBossAS 4.0.5 GA (the latest stable version in the 4.0.x series). 4.0.0 is too old (not that the issue you are running into is related). This wiki shows you that 4.0.5 can be run with JDK 1.4 http://jboss.org/community/docs/DOC-10809