1 2 Previous Next 20 Replies Latest reply on Dec 17, 2008 3:14 AM by Andrea Gazzarini

    Problem with inheritance and JBossWS

    Marco Strauch Newbie

      I have a problem with the new JBossWS-1.2.1.GA in JBoss 4.2.0.GA and inheritance.
      To describe this problem first I have to describe my code structure:

      For an example I have three classes (ClassA, ClassB and ClassC). ClassC inherits of ClassB and ClassB inherits of ClassA (ClassA --> ClassB --> ClassC). Now I have a webservice method that returns ClassB. In this method an instance of ClassC is being created and returned. This was not a problem in the former JBossWS version (and also in the other J2EE 4 styled webservices) but now in JBossWS 1.2 I only get returned an object of ClassB but I supposed to get an obejct of ClassC.


      public class ClassA {
       private String propA;
      
       // here setter and getter for propA
      ......
      }
      
      public class ClassB extends ClassA {
      
       private String propB;
       // here setter and getter for propB
      ......
      }
      
      public class ClassC extends ClassC {
       private String propC;
       // here setter and getter for propC
      ......
      }
      
      @WebService
      @SOAPBinding( style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED )
      public class MyWebService {
      
       @WebMethod()
       public ClassB getClassB() {
       ClassC classC = new ClassC();
       classC.setPropA("propA");
       return classC;
       }
      
       /**
       * --> this method is only used to publish ClassC otherwise it is not known
       * in this webservice
       */
       @WebMethod()
       public ClassC getClassC() {
       ClassC classC = new ClassC();
       classC.setPropA("propA");
       return classC;
       }
      
      }
      
      }



      Now I call getClassB() and the result that I got is an object of ClassB and not of ClassC.

      What can I do to get an object of ClassC. I also looked at the returned SOAP message and there you can see that only informations about the ClassB instance are submitted. In JBoss 4.0.5 (JBossWS1.0.3) the SOAP message contains the type of the returned object and all data are being submitted correctly.

      I also tried the SOAP parameter style BARE but nothing changed. And whenI use RPC/Literal then I get an error in the .NET Client that an instance of ClassB was expected but got an instance of ClassC. I also tried it with a JAVA client but there was the same occurance.

      Any help would be appreciated!

      Marco.

        • 1. Re: Problem with inheritance and JBossWS
          Thomas Diesler Master

          If like to get involved please add a testcase to our testsuite

          http://jira.jboss.org/jira/browse/JBWS-1702

          • 2. Re: Problem with inheritance and JBossWS
            Hannes Koller Newbie

            I tried to post this in JIRA but it told me I dont have permission to comment on the issue so here it goes:

            I am experiencing the same problem described by original Reporter: Subclass information gets lost when the SOAP message is created....but not always.. if the class contains a variable of JAXBElement then the inheritance seems to work correctly for all attributes in the class.

            Example (constructed to explain my point, sorry if not 100% correct but the WSDL I am really dealing with is quite huge).

            <complexType name="SomeType">
             <complexContent>
             <sequence>
             <element name="someElement" type="tns:SomeElement" minOccurs="0" maxOccurs="1"nillable="true"/>
             <element name="classB" type="tns:ClassB" minOccurs="1" maxOccurs="1" nillable="true" />
             </sequence>
             </complexContent>
            </complexType>
            

            Note that the minOccurrs="0" together with nillable="true" in someElement will cause wsconsume to create the JAXBElement<..> variable i was talking about:

            public class SomeType{
            
             @XmlElementRef(name = "someElement", namespace = "http://some.namespace.com", type = JAXBElement.class)
             protected JAXBElement<SomeElement> someElement;
             @XmlElement(required = true, nillable = true)
             protected ClassB classB;
            ....
            


            In this example inheritance for the classB Attribute works as expected. Whereas if I alter the wsdl and set the minOccurrs of someElement to 1 thus having wsconsume create the following class:

            public class SomeType{
            
             @XmlElement(required=true, nillable=true)
             protected SomeElement someElement;
             @XmlElement(required = true, nillable = true)
             protected ClassB classB;
            ...
            
            

            then inheritance on classB breaks.


            Not sure why this is happening, but I thought this observation might help to track down the cause of this.




            • 3. Re: Problem with inheritance and JBossWS
              Marco Strauch Newbie

              I tried to create an own JAXBElement as you described. But I am getting errors when I deploy it. First I create an ObjectFactory for "someElement":

              @XmlRegistry
              class ObjectFactory {
              
               @XmlElementDecl(scope=getClassBResponse.class, name="someElement", namespace="http://some.namespace.com")
               JAXBElement<String> createSomeElement(String s) {
               return new JAXBElement<String>(new QName("someElement"), String.class, s);
               }
              }
              


              Then I defined the JAXBElement in my response class
              @XmlAccessorType(XmlAccessType.FIELD)
              @XmlType(name = "getClassBResponse", namespace="http://mstrauch.examples.ws/", propOrder = { "data", "someElement" })
              public class getClassBResponse {
              
               @XmlElementRef(name = "someElement", namespace = "http://some.namespace.com", type = JAXBElement.class)
               protected JAXBElement<String> someElement;
              
               @XmlElement(required = true, nillable = true)
               protected ClassB data;
              
               public getClassBResponse() {
               }
              
               public ClassB getData() {
               return data;
               }
              
               public void setData(ClassB data) {
               this.data = data;
               }
              
              }
              


              During deployment I am getting a ClassCastException:



              org.jboss.deployment.DeploymentException: Cannot start service endpoint; - nested throwable: (java.lang.ClassCastException: mstrauch.examples.ws.jaxws.GetClassCAsClassBResponse$JaxbAccessorM_getReturn
              _setReturn_mstrauch_examples_ws_types_ClassB)
              at org.jboss.deployment.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:53)
              at org.jboss.ws.integration.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:101)
              at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
              at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
              at $Proxy46.start(Unknown Source)
              at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
              at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
              at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
              at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
              at $Proxy9.deploy(Unknown Source)
              at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
              at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
              at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
              Caused by: java.lang.ClassCastException: mstrauch.examples.ws.jaxws.GetClassCAsClassBResponse$JaxbAccessorM_getReturn_setReturn_mstrauch_examples_ws_types_ClassB
              at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.instanciate(OptimizedAccessorFactory.java:151)
              at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:96)
              at com.sun.xml.bind.v2.runtime.reflect.Accessor$GetterSetterReflection.optimize(Accessor.java:308)
              at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.(SingleElementNodeProperty.java:53)
              at sun.reflect.GeneratedConstructorAccessor62.newInstance(Unknown Source)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
              at com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:88)
              at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.(ClassBeanInfoImpl.java:135)
              at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:404)
              at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:246)
              at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
              at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
              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:585)
              at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
              at javax.xml.bind.ContextFinder.find(ContextFinder.java:368)
              at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
              at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
              at org.jboss.ws.metadata.acessor.JAXBAccessor$1.create(JAXBAccessor.java:67)
              at org.jboss.ws.metadata.acessor.JAXBAccessor$1.create(JAXBAccessor.java:54)
              at org.jboss.ws.metadata.umdm.ParameterMetaData.eagerInitialize(ParameterMetaData.java:470)
              at org.jboss.ws.metadata.umdm.OperationMetaData.eagerInitialize(OperationMetaData.java:469)
              at org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitializeOperations(EndpointMetaData.java:516)
              at org.jboss.ws.metadata.umdm.EndpointMetaData.initializeInternal(EndpointMetaData.java:502)
              at org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitialize(EndpointMetaData.java:490)
              at org.jboss.ws.metadata.umdm.ServiceMetaData.eagerInitialize(ServiceMetaData.java:429)
              at org.jboss.ws.metadata.umdm.UnifiedMetaData.eagerInitialize(UnifiedMetaData.java:192)
              at org.jboss.ws.core.server.ServiceEndpoint.start(ServiceEndpoint.java:112)
              at org.jboss.ws.core.server.ServiceEndpointManager.startServiceEndpoint(ServiceEndpointManager.java:646)
              at org.jboss.ws.core.server.ServiceEndpointDeployer.start(ServiceEndpointDeployer.java:140)
              at org.jboss.ws.integration.jboss42.DeployerInterceptor.startServiceEndpoint(DeployerInterceptor.java:144)
              at org.jboss.ws.integration.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:96)
              ... 28 more



              So what can I do?

              • 4. Re: Problem with inheritance and JBossWS
                Hannes Koller Newbie

                Hmm interesting. As I said I started with a wsdl file and used wsconsume to create the Java Classes and annotations. I have not touched the Java classes or the ObjectFactory manually.

                When I find the time I will try to create a complete, minimal example.

                • 5. Re: Problem with inheritance and JBossWS
                  Marco Strauch Newbie

                  I have testet a little bit more and now I have a little example that I can deploy. I also startet with the wsdl file and used wsconsume to create the java classes and annotation. Then I copied these classes in my project and so the deployment was successful. But when I access the deployed webservice I am getting a ClassCastException during the request.

                  Below I list my classes:

                  ClassA

                  @XmlAccessorType(XmlAccessType.FIELD)
                  @XmlType(name = "classA", propOrder = {
                   "propA"
                  })
                  public class ClassA {
                  
                   private String propA;
                  
                   public ClassA() {
                   }
                  
                   public String getPropA() {
                   return propA;
                   }
                  
                   public void setPropA(String propA) {
                   this.propA = propA;
                   }
                  
                  }
                  


                  ClassB
                  @XmlAccessorType(XmlAccessType.FIELD)
                  @XmlType(name = "classB", propOrder = {
                   "propB"
                  })
                  public class ClassB extends ClassA {
                   private String propB;
                   public ClassB() {
                   }
                  
                   public String getPropB() {
                   return propB;
                   }
                  
                   public void setPropB(String propB) {
                   this.propB = propB;
                   }
                  }
                  


                  ClassC
                  @XmlAccessorType(XmlAccessType.FIELD)
                  @XmlType(name = "classC", propOrder = {
                   "propC"
                  })
                  public class ClassC extends ClassB {
                  
                   private String propC;
                   public ClassC() {
                   }
                  
                   public String getPropC() {
                   return propC;
                   }
                  
                   public void setPropC(String propC) {
                   this.propC = propC;
                   }
                  }
                  

                  GetClassBResponse
                  @XmlAccessorType(XmlAccessType.FIELD)
                  @XmlType(name = "getClassBResponse", propOrder = {
                   "someElement",
                   "data"
                  })
                  public class GetClassBResponse {
                  
                   @XmlElementRef(name = "someElement", type = JAXBElement.class)
                   protected JAXBElement<String> someElement;
                   @XmlElement(required = true, nillable = true)
                   protected ClassB data;
                  
                   public JAXBElement<String> getSomeElement() {
                   return someElement;
                   }
                  
                   public void setSomeElement(JAXBElement<String> value) {
                   this.someElement = ((JAXBElement<String> ) value);
                   }
                  
                   public ClassB getData() {
                   return data;
                   }
                  
                   public void setData(ClassB value) {
                   this.data = value;
                   }
                  }
                  

                  SampleWSWithDocument_Bare
                  @WebService()
                  @SOAPBinding( style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.BARE )
                  public class SampleWSWithDocument_Bare {
                  
                   public SampleWSWithDocument_Bare() {
                   }
                  
                   @WebMethod()
                   public GetClassBResponse getClassCAsClassB() {
                   System.out.print("getClassCAsClassB");
                   ClassC classC= new ClassC();
                   classC.setPropA("propA");
                   classC.setPropB("propB");
                   classC.setPropC("propC");
                  
                   GetClassBResponse resp = new GetClassBResponse();
                   resp.setData(classC);
                  
                   ObjectFactory fact = new ObjectFactory();
                   resp.setSomeElement(fact.createGetClassBResponseSomeElement("Test"));
                   return resp;
                   }
                  }
                  


                  ObjectFactory
                  @XmlRegistry
                  public class ObjectFactory {
                  
                   private final static QName _GetClassCAsClassBResponse_QNAME = new QName("http://ws.examples.mstrauch/", "getClassCAsClassBResponse");
                   private final static QName _GetClassBResponseSomeElement_QNAME = new QName("http://ws.examples.mstrauch/", "someElement");
                  
                   public ObjectFactory() {
                   }
                  
                   public ClassA createClassA() {
                   return new ClassA();
                   }
                  
                   public ClassC createClassC() {
                   return new ClassC();
                   }
                  
                   public ClassB createClassB() {
                   return new ClassB();
                   }
                  
                   public GetClassBResponse createGetClassBResponse() {
                   return new GetClassBResponse();
                   }
                  
                   @XmlElementDecl(namespace = "http://ws.examples.mstrauch/", name = "getClassCAsClassBResponse")
                   public JAXBElement<GetClassBResponse> createGetClassCAsClassBResponse(GetClassBResponse value) {
                   return new JAXBElement<GetClassBResponse>(_GetClassCAsClassBResponse_QNAME, GetClassBResponse.class, null, value);
                   }
                  
                   @XmlElementDecl(namespace = "http://ws.examples.mstrauch/", name = "someElement", scope = GetClassBResponse.class)
                   public JAXBElement<String> createGetClassBResponseSomeElement(String value) {
                   return new JAXBElement<String>(_GetClassBResponseSomeElement_QNAME, String.class, GetClassBResponse.class, value);
                   }
                  }
                  


                  Now I get follow error message during request.


                  08:59:41,554 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
                  javax.xml.soap.SOAPException: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
                  at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:68)
                  at org.jboss.ws.core.soap.SOAPFactoryImpl.createElement(SOAPFactoryImpl.java:120)
                  at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:116)
                  at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:85)
                  at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:254)
                  at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:179)
                  at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:197)
                  at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
                  at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                  at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                  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:230)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                  at java.lang.Thread.run(Thread.java:595)
                  Caused by: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
                  at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:64)
                  ... 29 more
                  08:59:41,632 ERROR [SOAPFaultHelperJAXWS] Error creating SOAPFault message
                  javax.xml.soap.SOAPException: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
                  at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:77)
                  at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.toSOAPMessage(SOAPFaultHelperJAXWS.java:234)
                  at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:164)
                  at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:104)
                  at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:623)
                  at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:229)
                  at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
                  at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                  at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                  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:230)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                  at java.lang.Thread.run(Thread.java:595)
                  Caused by: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
                  at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:73)
                  ... 28 more
                  08:59:41,632 ERROR [AbstractServiceEndpointServlet] Error processing web service request
                  javax.xml.ws.WebServiceException: Cannot create SOAPFault message for: javax.xml.soap.SOAPException: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
                  at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:172)
                  at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:104)
                  at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:623)
                  at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:229)
                  at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
                  at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                  at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                  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:230)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                  at java.lang.Thread.run(Thread.java:595)
                  08:59:41,632 ERROR [[SampleWSWithDocument_Bare]] Servlet.service() for servlet SampleWSWithDocument_Bare threw exception
                  javax.xml.ws.WebServiceException: Cannot create SOAPFault message for: javax.xml.soap.SOAPException: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
                  at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:172)
                  at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:104)
                  at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:623)
                  at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:229)
                  at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
                  at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                  at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                  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:230)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                  at java.lang.Thread.run(Thread.java:595)



                  • 6. Re: Problem with inheritance and JBossWS
                    Hannes Koller Newbie

                    Ok I have managed to create a simple example of the behavior. Please note that I am pretty new to webservices and JBossWS (started using it a few days ago) so sorry if something is overly complicated. Feedback is highly appreciated.

                    I am using JBoss 4.2.0.GA and java version "1.5.0_08"

                    I started with the following WSDL (I have modified an echo tutorial I found on the web so please dont be confused by the namespace and other irregularities):

                    <?xml version="1.0" encoding="UTF-8"?>
                    <definitions name='EchoService' targetNamespace='http://echo/'
                     xmlns='http://schemas.xmlsoap.org/wsdl/'
                     xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
                     xmlns:tns='http://echo/'
                     xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
                     <types>
                     <xs:schema targetNamespace='http://echo/' version='1.0'
                     xmlns:tns='http://echo/'
                     xmlns:xs='http://www.w3.org/2001/XMLSchema'>
                    
                     <xs:complexType name='Something'>
                     <xs:sequence>
                     <xs:element minOccurs='0' name='arg0' type='xs:string' />
                     </xs:sequence>
                     </xs:complexType>
                    
                     <xs:complexType name='A'>
                     <xs:sequence>
                     <xs:element minOccurs='0' name='arg0' type='xs:string' />
                     </xs:sequence>
                     </xs:complexType>
                    
                     <xs:complexType name='B'>
                     <xs:complexContent>
                     <xs:extension base="tns:A">
                     <xs:sequence>
                     <xs:element minOccurs='0' name='arg1' type='xs:string' />
                     </xs:sequence>
                     </xs:extension>
                     </xs:complexContent>
                     </xs:complexType>
                     <xs:complexType name='C'>
                     <xs:complexContent>
                     <xs:extension base="tns:B">
                     <xs:sequence>
                     <xs:element minOccurs='0' name='arg2' type='xs:string' />
                     </xs:sequence>
                     </xs:extension>
                     </xs:complexContent>
                     </xs:complexType>
                    
                     <xs:complexType name="BResponse">
                     <xs:sequence>
                     <xs:element name="something" type="tns:Something" minOccurs="1" maxOccurs="1" nillable="true"/>
                     <xs:element name="b" type="tns:B" minOccurs="1" maxOccurs="1" nillable="true"/>
                     </xs:sequence>
                     </xs:complexType>
                    
                     <xs:element name="bResponse" type="tns:BResponse"/>
                     <xs:element name="something" type="tns:Something"/>
                     </xs:schema>
                     </types>
                    
                     <message name='GetB_Request' />
                    
                     <message name='GetB_GetBResponse'>
                     <part name='para' element="tns:bResponse"/>
                     </message>
                    
                     <portType name='GetB'>
                     <operation name='getB' >
                     <input message='tns:GetB_Request'/>
                     <output message='tns:GetB_GetBResponse' />
                     </operation>
                     </portType>
                     <binding name='GetBBinding' type='tns:GetB'>
                     <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http' />
                     <operation name='getB'>
                     <soap:operation soapAction='' />
                     <input>
                     <soap:body use='literal' />
                     </input>
                     <output>
                     <soap:body use='literal' />
                     </output>
                     </operation>
                     </binding>
                     <service name='GetBService'>
                     <port binding='tns:GetBBinding' name='GetBPort'>
                     <soap:address location='REPLACE_WITH_ACTUAL_URL' />
                     </port>
                     </service>
                    </definitions>
                    


                    We have an A->B->C Class Hierarchy here, and a BResponse Complex Type which consists of a "B" and a "Something". Note the "minOccurs=1 maxOccurs=1 nillable=true " . If I throw the file at wsconsume it creates a number of classes. The BResponse Class looks like this:

                    @XmlAccessorType(XmlAccessType.FIELD)
                    @XmlType(name = "BResponse", propOrder = {
                     "something",
                     "b"
                    })
                    public class BResponse {
                    
                     @XmlElement(required = true, nillable = true)
                     protected Something something;
                     @XmlElement(required = true, nillable = true)
                     protected B b;
                    ....}
                    



                    I have written a very simple Server:

                    @javax.jws.WebService(endpointInterface="echo.GetB", serviceName="GetBService", targetNamespace="http://echo/", portName="GetBPort" )
                    public class DummyGetB implements GetB {
                    
                     public BResponse getB() {
                    
                     BResponse response = new BResponse();
                    
                     C c = new C();
                     c.setArg0("1");
                     c.setArg1("2");
                     c.setArg2("3");
                    
                     response.setB(c);
                    
                     return response;
                     }
                    
                    }
                    



                    and a Client:

                    public class Client {
                    
                     public static void main(String[] args) throws Exception {
                     GetBService getB = new GetBService(new URL("http://127.0.0.1:8080/server?wsdl"),new QName("http://echo/", "GetBService"));
                    
                     GetB getBPort = getB.getGetBPort();
                     BResponse bResponse = getBPort.getB();
                    
                     System.out.println(bResponse.getB().getClass());
                     B b = bResponse.getB();
                     System.out.println(b.getArg0());
                     System.out.println(b.getArg1());
                     C c = (C)bResponse.getB();
                     System.out.println(c.getArg2());
                     }
                    


                    If I try this example I get:

                    class echo.B
                    1
                    2
                    Exception in thread "main" java.lang.ClassCastException: echo.B
                     at at.ac.arsenal.Client.main(Client.java:53)
                    


                    Only a "B" gets transmitted, although it should be a "C"

                    Now, to get the behavior I was talking about change the minOccurrs parameter of something element of BResponse to 0:

                     ..............
                     <xs:complexType name="BResponse">
                     <xs:sequence>
                     <xs:element name="something" type="tns:Something" minOccurs="0" maxOccurs="1" nillable="true"/>
                     <xs:element name="b" type="tns:B" minOccurs="1" maxOccurs="1" nillable="true"/>
                     </xs:sequence>
                     </xs:complexType>
                     ................
                    


                    Then rerun wsconsume. The generated BResponse class now looks like this. Notice the JAXBElement type of variable something;

                    @XmlAccessorType(XmlAccessType.FIELD)
                    @XmlType(name = "BResponse", propOrder = {
                     "something",
                     "b"
                    })
                    public class BResponse {
                    
                     @XmlElementRef(name = "something", type = JAXBElement.class)
                     protected JAXBElement<Something> something;
                     @XmlElement(required = true, nillable = true)
                     protected B b;
                    


                    I Recompile and Redeploy the server then rerun the Client. The output is now:

                    class echo.C
                    1
                    2
                    3
                    


                    now C gets transmitted and the arg2 property has the correct value.

                    As I said before this is of course no solution to the original problem, but I think it might be useful in tracking down the source of it.




                    • 7. Re: Problem with inheritance and JBossWS
                      Hannes Koller Newbie

                      Here are the generated XML fragments (read from the JBoss log):

                      Incorrect Behavior (B Transmitted)

                      <ns1:bResponse xmlns:ns1="http://echo/">
                       <something xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
                       <b>
                       <arg0>1</arg0>
                       <arg1>2</arg1>
                       </b>
                      </ns1:bResponse>
                      


                      Correct Behavior(C Transmitted)
                      <ns2:bResponse xmlns:ns2="http://echo/">
                       <b xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:C">
                       <arg0>1</arg0>
                       <arg1>2</arg1>
                       <arg2>3</arg2>
                       </b>
                      </ns2:bResponse>
                      


                      Perhaps that helps :-)

                      • 8. Re: Problem with inheritance and JBossWS
                        Raju Koganty Newbie

                        JBossWS 2.0.1 release notes say that JBWS-1702 is fixed which solves the inheritance problem, but looks like it is still not fixed.

                        I'm usinf JBossWS 2.0.1 with JBoss 4.0.5.
                        I've tried both jdk 1.5 anf jdk 1.6.

                        • 10. Re: Problem with inheritance and JBossWS
                          Raju Koganty Newbie

                          I am already using the XmlSeeAlso..

                          @XmlSeeAlso({Aa.class, Aaa.class})
                          public class A
                          {
                          }

                          @XmlSeeAlso(Aaa.class)
                          public class Aa extends A
                          {
                          }

                          public class Aaa extends Aa
                          {}

                          And the WebService ..

                          @WebService
                          @SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
                          use = SOAPBinding.Use.LITERAL,
                          parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
                          @Stateless
                          @RemoteBinding(jndiBinding=LookupConstants.CLIENT_MANAGER)
                          @Depends({LookupConstants.CLIENT_SERVICE_OBJECT_NAME})
                          public class ClientManagerBean implements ClientManager
                          {

                          @WebMethod
                          public A getA(int i)
                          {
                          A a = null;
                          switch(i)
                          {
                          case 1:
                          a = new Aa();
                          break;
                          case 2:
                          a = new Aa();
                          break;
                          case 3:
                          a = new Aaa();
                          break;
                          }
                          return a;
                          }

                          }

                          This always returns just an object of type A on the Client side no matter what args I pass.
                          I do not know what I'm missing...

                          • 11. Re: Problem with inheritance and JBossWS
                            Heiko Braun Master

                            Are you using the same playoad beans on the client side?

                            How does SOAP Message look like?

                            • 12. Re: Problem with inheritance and JBossWS
                              Raju Koganty Newbie

                              Client is using the beans generated from the WSDL. Looks like after some minor changes on the server finally, the SOAP response looks right..but is not being materialized into the right type of object :

                              <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
                               <env:Header/>
                               <env:Body>
                               <ns2:getAResponse xmlns:ns2="http://impl.beans.client.server.epicenter.extremenetworks.com/">
                               <return
                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="aa">
                               <a>A</a>
                               <b>B</b>
                               </return>
                               </ns2:getAResponse>
                               </env:Body>
                              </env:Envelope>
                              

                              The object still shows up as of type A and not Aa.

                              The generated beans look like this :

                              @XmlAccessorType(XmlAccessType.FIELD)
                              @XmlType(name = "a", propOrder = {
                               "a"
                              })
                              @XmlSeeAlso({
                               Aa.class
                              })
                              public class A {
                              
                               protected String a;
                              ..
                              
                              
                              @XmlAccessorType(XmlAccessType.FIELD)
                              @XmlType(name = "aa", propOrder = {
                               "b"
                              })
                              @XmlSeeAlso({
                               Aaa.class
                              })
                              public class Aa
                               extends A
                              {
                              
                               protected String b;
                              ....
                              
                              
                              @XmlAccessorType(XmlAccessType.FIELD)
                              @XmlType(name = "aaa", propOrder = {
                               "c"
                              })
                              public class Aaa
                               extends Aa
                              {
                              
                               protected String c;
                              .....
                              


                              • 13. Re: Problem with inheritance and JBossWS
                                manoj rokka Newbie

                                I also have the same problem. I have used jboss4.2.0+jbossws2.0.1+jdk 1.5. I tried using @XmlSeeAlso on base class but it also can't solved my porblem.
                                I have the following situation:

                                My Pojo classes
                                @XmlSeeAlso({B.class,C.class})
                                public class A extends java.io.Serializable{
                                }

                                public class B extends A{
                                }

                                public class C extends A{
                                }

                                Now webservice
                                @WebService(name = "MyWebServicePortType", serviceName = "MyWebService",
                                portName = "MyWebServicePort",targetNamespace = "http://mywebservice.com")

                                @SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
                                use = SOAPBinding.Use.LITERAL,
                                parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
                                public class MyWebService{
                                @WebMethod
                                public String getClassName(A obj){
                                String className=obj.getClass().getName();
                                return className; //it always returns ?A? on jbossWS2.0.1 even if I pass the reference of B while calling this function from client
                                }
                                }

                                Does anybody knows the solution?

                                1 2 Previous Next