1 Reply Latest reply on Apr 19, 2013 7:43 AM by jewallie

    java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.Envelope1_1Impl cannot be cast to org.jboss.ws.core.soap.SOAPElementImpl

    jewallie

      Hey guys,

       

      I'm currently working on a new web service for my company where I currently am trainee. However I'm pretty new to web services and I get this very weird error, and I am completely stuck on this one.

      I was hoping if anyone could help me out.

       

      The web service is running on a JBoss 5.1 server and it's running Java 1.6 and so am I.

      After deploying the web service it succesfully generates the .wsdl file, and I'm able to generate some stub classes. However when I call the stub, to launch the web service method, I get this weird error:

       

      ERROR [org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS] (http-0.0.0.0-8080-7) SOAP request exception
      java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.Envelope1_1Impl cannot be cast to org.jboss.ws.core.soap.SOAPElementImpl
          at org.jboss.ws.core.soap.SOAPEnvelopeImpl.<init>(SOAPEnvelopeImpl.java:57)
          at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:136)
          at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:96)
          at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:294)
          at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:193)
          at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:449)
          at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:293)
          at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:203)
          at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:129)
      ...
      ERROR [org.jboss.wsf.stack.jbws.RequestHandlerImpl] (http-0.0.0.0-8080-7) Error processing web service request
      org.jboss.ws.WSException: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl cannot be cast to org.jboss.ws.core.soap.MessageFactoryImpl
          at org.jboss.ws.WSException.rethrow(WSException.java:68)
          at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:330)
          at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:203)
          at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:129)
          at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
          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)
      ...
      INFO  [STDOUT] (http-0.0.0.0-8080-5) 
      #####################################
      # ERROR in WRI [20130419-090510-944]: 
      # AxisFault
      #  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
      #  faultSubcode: 
      #  faultString: org.xml.sax.SAXParseException: Premature end of file.
      #  faultActor: 
      #  faultNode: 
      #  faultDetail: 
      #     {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Premature end of file.
      #     at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
      #     at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
      #     at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      #     at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      #     at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      #     at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
      #     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      #     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      #     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      #     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      #     at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      #     at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
      ...
      

       

      This is my web service class:

       

      @WebService(
              name = "Test",
              serviceName = "testservice",
              portName = "TestService",
              targetNamespace = "http://testservice.example.com")
      @SOAPBinding(
              style = SOAPBinding.Style.DOCUMENT,
              parameterStyle = SOAPBinding.ParameterStyle.WRAPPED,
              use = SOAPBinding.Use.LITERAL)
      public class TestService implements Serializable {
      
      
          @Resource
          private WebServiceContext ctx;
      
      
          public void init(Object o) {
              setServiceContext(o);
          }
      
      
          public void destroy() {
          }
      
      
          public WebServiceContext getServiceContext() {
              return ctx;
          }
      
      
          protected void setServiceContext(Object o) {
              this.ctx = (WebServiceContext) o;
          }
      
      
          @WebMethod(action = "http://service.example.com/test")
          @RequestWrapper(localName = "testElement")
          @ResponseWrapper(localName = "testResponseElement")
          public String test(
                  @WebParam(name = "test") String test,
                  @WebParam(name = "test2") String test2) {
              return test + " + " + test2;
          }
      }
      

       

      And this is how I call my stub (which interacts with the web service):

       

      Testservice locator = new TestserviceLocator();
      TestService service = locator.getTestService();
      Test test = new Test("hello", "world");
      System.out.println(service.test(test).get_return());
      

       

      Thanks in advance.