1 Reply Latest reply on Apr 17, 2014 6:10 AM by Marthin Bergstrand

    WebService throws ClasscastException in JBoss5

    Atul Kaushal Newbie

      Hello,

      I have a class that invokes a WEB SERVICE deployed on the different Jboss. Both application servers has same enviornment is JDK1.6,and JBoss5.

      Here is a code portion:

      <code>

      System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration","org.apache.xerces.parsers.XIncludeAwareParserConfiguration");

       

        final Document doc = this.generateXMLDoc((List) listData);

                                    final String strXMLData = "TestString";

                                    final String endpointURL = PropertyHandler.getValue("printWebServiceEndPoint");

                                    final TestWebService testWebService = new TestWebService(new URL(endpointURL), new QName(

                                                        "http://test.webservice.xyz/", "TestWebService"));

                                    final TestService tservice = testWebService.getTestServicePort();

                                    final String msg = tservice.print(strXMLData);

                                    if (msg.equals("Abc"))

                                    {

                                              return false;

                                    }

                                    return true;

      </code>


      I have following jar in my JBOSS_HOME/lib/endorsed directory.

      • activation.jar
      • resolver.jar
      • serializer.jar
      • stax-api.jar
      • xalan.jar
      • xercesImpl.jar
      • jaxb-api.jar

       

      It was working fine on JBoss4.2.2GA but its breaking on JBoss 5 and throws error given below.

       

      01:50:46,760 INFO  [STDOUT] ERROR 01:50:46,759 (TestServiceInputXMLParser) - com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext

      java.lang.ClassCastException: com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext

              at org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitializeAccessors(EndpointMetaData.java:665)

              at org.jboss.ws.metadata.umdm.EndpointMetaData.initializeInternal(EndpointMetaData.java:545)

              at org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitialize(EndpointMetaData.java:533)

              at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.rebuildEndpointMetaData(JAXWSClientMetaDataBuilder.java:312)

              at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPortInternal(ServiceDelegateImpl.java:269)

              at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java:200)

              at javax.xml.ws.Service.getPort(Service.java:99)

              at edu.wustl.webservice.catissuecore.test.TestWebService.getTestServicePort(TestWebService.java:50)

              at edu.wustl.catissuecore.testservicemodule.TestServiceInputXMLParser.callTestService(TestServiceInputXMLParser.java:81)

              at edu.wustl.catissuecore.action.TestAction.executeXSS(TestAction.java:159)

              at edu.wustl.common.action.XSSSupportedAction.checkForXSSViolation(XSSSupportedAction.java:170)

              at edu.wustl.common.action.XSSSupportedAction.execute(XSSSupportedAction.java:76)

              at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)

              at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)

              at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)

              at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)

              at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)

              at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)

              at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)

              at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)

              at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)

              at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)

              at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)

              at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)

              at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)

              at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.owasp.stinger.StingerFilter.doStinger(StingerFilter.java:365)

              at org.owasp.stinger.StingerFilter.doStingerFilter(StingerFilter.java:293)

              at org.owasp.stinger.StingerFilter.doFilter(StingerFilter.java:122)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

              at java.lang.Thread.run(Thread.java:662)

      01:50:46,762 ERROR [STDERR] java.lang.ClassCastException: com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext

      01:50:46,763 ERROR [STDERR]     at org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitializeAccessors(EndpointMetaData.java:665)

      01:50:46,764 ERROR [STDERR]     at org.jboss.ws.metadata.umdm.EndpointMetaData.initializeInternal(EndpointMetaData.java:545)

      01:50:46,765 ERROR [STDERR]     at org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitialize(EndpointMetaData.java:533)

      01:50:46,766 ERROR [STDERR]     at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.rebuildEndpointMetaData(JAXWSClientMetaDataBuilder.java:312)

      01:50:46,767 ERROR [STDERR]     at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPortInternal(ServiceDelegateImpl.java:269)

      01:50:46,768 ERROR [STDERR]     at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java:200)

      01:50:46,769 ERROR [STDERR]     at javax.xml.ws.Service.getPort(Service.java:99)

      01:50:46,769 ERROR [STDERR]     at edu.wustl.webservice.catissuecore.test.TestWebService.getTestServicePort(TestWebService.java:50)

      01:50:46,770 ERROR [STDERR]     at edu.wustl.catissuecore.testservicemodule.TestServiceInputXMLParser.callTestService(TestServiceInputXMLParser.java:81)

      01:50:46,828 ERROR [STDERR]     at edu.wustl.catissuecore.action.TestAction.executeXSS(TestAction.java:159)

      01:50:46,829 ERROR [STDERR]     at edu.wustl.common.action.XSSSupportedAction.checkForXSSViolation(XSSSupportedAction.java:170)

      01:50:46,830 ERROR [STDERR]     at edu.wustl.common.action.XSSSupportedAction.execute(XSSSupportedAction.java:76)

      01:50:46,830 ERROR [STDERR]     at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)

      01:50:46,832 ERROR [STDERR]     at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)

      01:50:46,832 ERROR [STDERR]     at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)

      01:50:46,833 ERROR [STDERR]     at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

      01:50:46,834 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

      01:50:46,834 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

      01:50:46,835 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

      01:50:46,836 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      01:50:46,836 ERROR [STDERR]     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)

      01:50:46,837 ERROR [STDERR]     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)

      01:50:46,838 ERROR [STDERR]     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)

      01:50:46,838 ERROR [STDERR]     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)

      01:50:46,839 ERROR [STDERR]     at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)

      01:50:46,840 ERROR [STDERR]     at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)

      01:50:46,840 ERROR [STDERR]     at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)

      01:50:46,841 ERROR [STDERR]     at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)

      01:50:46,842 ERROR [STDERR]     at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)

      01:50:46,842 ERROR [STDERR]     at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)

      01:50:46,843 ERROR [STDERR]     at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

      01:50:46,844 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

      01:50:46,845 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

      01:50:46,845 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

      01:50:46,846 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      01:50:46,847 ERROR [STDERR]     at org.owasp.stinger.StingerFilter.doStinger(StingerFilter.java:365)

      01:50:46,847 ERROR [STDERR]     at org.owasp.stinger.StingerFilter.doStingerFilter(StingerFilter.java:293)

      01:50:46,848 ERROR [STDERR]     at org.owasp.stinger.StingerFilter.doFilter(StingerFilter.java:122)

      01:50:46,849 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

      01:50:46,850 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      01:50:46,851 ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      01:50:46,851 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

      01:50:46,852 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      01:50:46,853 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

      01:50:46,853 ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

      01:50:46,854 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

      01:50:46,855 ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

      01:50:46,855 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

      01:50:46,856 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

      01:50:46,857 ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

      01:50:46,857 ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      01:50:46,858 ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

      01:50:46,859 ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      01:50:46,859 ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

      01:50:46,860 ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

      01:50:46,860 ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

      01:50:46,861 ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

      01:50:46,862 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:662)

        • 1. Re: WebService throws ClasscastException in JBoss5
          Marthin Bergstrand Newbie

          You have hopefully found a solution to this by now but I had the same problem and I thought I´d give a recommendation.

           

          The problem for me was that I included my own version of jaxb-impl.jar because I used the following maven dependency

           

          <dependency>

            <groupId>org.apache.cxf</groupId>

            <artifactId>cxf-rt-frontend-jaxws</artifactId>

            <version>${cxf.version}</version>

            </dependency>

           

          I solved this by addin an exclusion to the jaxb-impl like this

           

          <dependency>

            <groupId>org.apache.cxf</groupId>

            <artifactId>cxf-rt-frontend-jaxws</artifactId>

            <version>${cxf.version}</version>

                                  <exclusions>

                                      <exclusion>

                                       <groupId>com.sun.xml.bind</groupId>

                                       <artifactId>jaxb-impl</artifactId>                            

                                      </exclusion>

                                   </exclusions>

            </dependency>

           

          The actual error was that the jaxb-impl.jar I included was for version jax-ws 2.1 and not 2.2 that I needed.