7 Replies Latest reply on Mar 21, 2012 6:55 PM by sfcoy

    EJB3 Webservice invocation failing with Unmarshalling Error

    thinksteep

      Hi Community,

       

      With your help I was able to migrate most of components from 4.2.3a to 7.1. We have a standalone application which frequently calls webservice (EJB3-JAXWS) and updates the status. This webservice and client invocation are working fine in 4.2.3a but failing in 7.1 with Unmarshalling Error message.

       

      Standalone application uses Axis2 for webservice invocation. Stack trace is little bit cryptic for me to understand. Any help would be really appreciated. Here is stack trace.

       

      18:03:11,163 INFO  [Connection][DcsInOutMessageDetails][machinename][test_jboss] some log message

      AxisFault

      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client

      faultSubcode:

      faultString: Unmarshalling Error: unexpected element (uri:"", local:&

      quot;item"). Expected elements are (none)

      faultActor:

      faultNode:

      faultDetail:

              {http://xml.apache.org/axis/}stackTrace:Unmarshalling Error: unexpected

      element (uri:"", local:"item"). Expected elements are (none)

       

              at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder

      .java:222)

              at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.

      java:129)

              at org.apache.axis.encoding.DeserializationContext.endElement(Deserializ

      ationContext.java:1087)

              at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source

      )

              at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknow

      n Source)

              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent

      Dispatcher.dispatch(Unknown Source)

              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un

      known 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 javax.xml.parsers.SAXParser.parse(SAXParser.java:395)

              at org.apache.axis.encoding.DeserializationContext.parse(Deserialization

      Context.java:227)

              at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)

              at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)

              at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.j

      ava:796)

              at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)

       

              at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg

      y.java:32)

              at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

              at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

              at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

              at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

              at org.apache.axis.client.Call.invoke(Call.java:2767)

              at org.apache.axis.client.Call.invoke(Call.java:2443)

              at org.apache.axis.client.Call.invoke(Call.java:2366)

              at org.apache.axis.client.Call.invoke(Call.java:1812)

              at com.name.yyy.dc.interactions.MyActionServiceBindin

      gStub.updateDataSourceLiveData(MyActionServiceBindingStub.java:375)

              at com.name.yyy.dc.interactions.MyActionServiceProxy.

      updateDataSourceLiveData(MyActionServiceProxy.java:90)

              at com.name.yyy.dc.interactions.BDSListener

      .send(BDSListener.java:103)

              at com.name.yyy.dc.interactions.BDSListener

      .access$000(BDSListener.java:47)

              at com.name.yyy.dc.interactions.BDSListener

      $1.run(BDSListener.java:124)

              at java.util.TimerThread.mainLoop(Timer.java:512)

              at java.util.TimerThread.run(Timer.java:462)

       

              {http://xml.apache.org/axis/}hostname:girin

       

      Unmarshalling Error: unexpected element (uri:"", local:"item"). Expected element

      s are (none)

              at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder

      .java:222)

              at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.

      java:129)

              at org.apache.axis.encoding.DeserializationContext.endElement(Deserializ

      ationContext.java:1087)

              at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source

      )

              at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknow

      n Source)

              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent

      Dispatcher.dispatch(Unknown Source)

              at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un

      known 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 javax.xml.parsers.SAXParser.parse(SAXParser.java:395)

              at org.apache.axis.encoding.DeserializationContext.parse(Deserialization

      Context.java:227)

              at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)

              at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)

              at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.j

      ava:796)

              at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)

       

              at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg

      y.java:32)

              at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

              at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

              at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

              at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

              at org.apache.axis.client.Call.invoke(Call.java:2767)

              at org.apache.axis.client.Call.invoke(Call.java:2443)

              at org.apache.axis.client.Call.invoke(Call.java:2366)

              at org.apache.axis.client.Call.invoke(Call.java:1812)

              at com.name.yyy.dc.interactions.MyActionServiceBindin

      gStub.updateDataSourceLiveData(MyActionServiceBindingStub.java:375)

              at com.name.yyy.dc.interactions.MyActionServiceProxy.

      updateDataSourceLiveData(MyActionServiceProxy.java:90)

              at com.name.yyy.dc.interactions.BDSListener

      .send(BDSListener.java:103)

              at com.name.yyy.dc.interactions.BDSListener

      .access$000(BDSListener.java:47)

              at com.name.yyy.dc.interactions.BDSListener

      $1.run(BDSListener.java:124)

              at java.util.TimerThread.mainLoop(Timer.java:512)

              at java.util.TimerThread.run(Timer.java:462)

        • 1. Re: EJB3 Webservice invocation failing with Unmarshalling Error
          sfcoy

          If this is a "bottom-up" web service then you may need to regenerate the client code using the wsdl generated by the new (7.1 hosted) implementation.

          • 2. Re: EJB3 Webservice invocation failing with Unmarshalling Error
            thinksteep

            Hi Stephen,

             

            Thank you for your reply!

             

            I am not sure whether it was done bottom-up (or) not. It was done long ago. I am porting the app from 4.2.3a to 7.1.

             

            I am sorry! I didn't get your comment "you may need to regenerate the client code using the wsdl generated by the new (7.1 hosted) implementation"

             

            I didn't modify/change any code related to Webservice (EJB3) while porting to 7.1, just deployed same EJB on 7.1,  Do I still need to regenrate client? Could you please provide more information?

             

            Thank you for your time and help.

             

            Thank you,

            Giri

            • 3. Re: EJB3 Webservice invocation failing with Unmarshalling Error
              sfcoy

              If it was "bottom-up", then this can be inherently non-portable so you will need to regenerate your client code from the server produced WSDL.

               

              Additionally, if your client is using Java 6 then Axis becomes irrelevant because Java 6 (post update 4) includes the JAX-WS 2.1 client machinery already.

               

              There's dozens of online tutorials around for this these days...

              • 4. Re: EJB3 Webservice invocation failing with Unmarshalling Error
                thinksteep

                Hi Stephen,

                 

                Thank you for the input. I guess your answered pointed me in valid direction. I am in process of regenrating clients and test. Will post if need any help.

                 

                Thank you,.

                • 5. Re: EJB3 Webservice invocation failing with Unmarshalling Error
                  thinksteep

                  Hi Stephen,

                   

                  How are you?

                   

                  May be my limited expereience on JAXWS or something, I couldn't find proper tutorials for this. What ever I found generating strange errors something like below: Can you provide good web references which can help me in this case.

                   

                  Operation on webservice accepts array of object say person, when I generated classes for WSDL, I got Person and PersonArray class.

                   

                  Then did something like below:

                   

                     PersonArray dtArray = new PersonArray();

                                  for(int i = 0; i<bdArray.length; i++)

                                  {

                                      PersonDTO bDTO = new PersonDTO();

                                      dtArray.getItem().add(bDTO);

                                  }

                                  AABeanService ser = new AABeanService();

                                  AAService service = ser.getAABeanPort();

                                  service.updateData(dtArray);

                   

                  Which resulted in below array.

                   

                  javax.xml.ws.WebServiceException: java.lang.NullPointerException

                          at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(Exc

                  eptionFactory.java:175)

                          at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(Excep

                  tionFactory.java:70)

                          at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(Excep

                  tionFactory.java:128)

                          at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.

                  execute(AxisInvocationController.java:559)

                          at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.

                  doInvoke(AxisInvocationController.java:118)

                          at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.

                  invoke(InvocationControllerImpl.java:82)

                          at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod

                  (JAXWSProxyHandler.java:317)

                          at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSPro

                  xyHandler.java:159)

                          at $Proxy26.updateData(Unknown Source)

                          at com.name.yyy.datacollector.interactions.DSEventListener

                  .send(DSEventListener.java:111)

                   

                   

                   

                  Thanks for your time and help.

                  • 6. Re: EJB3 Webservice invocation failing with Unmarshalling Error
                    thinksteep

                    Hi Stephen and community,

                     

                    It seems your suggestion worked. I was able to communicate with my service after re-genrating the classes.

                     

                    I am facing one more issue where your knowledge may help. One of the classes my service use has java.util.Properties as attribute, something like below:

                    MyDTO
                    {
                    Integer myInt;
                    Long myLong;
                    Properties myProperties;
                    } 

                     

                    Bottom-up approach generated WSDL like this:

                     

                    <xs:complexType name="MyDTO">
                       
                    <xs:sequence>
                           
                    <xs:element minOccurs="0" name="myInt" type="xs:int"/>
                           
                    <xs:element minOccurs="0" name="myLong" type="xs:long
                           
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="myProperties" nillable="true" type="xs:string"/>
                       
                    </xs:sequence>
                    </xs:complexType>

                     

                    From which I generated stub class, which resulted something like below:

                    @XmlAccessorType(XmlAccessType.FIELD)
                    @XmlType(name = "MyDTO", propOrder = {
                       
                    "myInt",
                       
                    "myLong",
                       
                    "myProperties",

                    })
                    MyDTO
                       
                    {
                       
                    Integer myInt;
                       
                    Long myLong;
                       
                    @XmlElement(nillable = true)
                       
                    List<String> myProperties;
                       
                    } 

                     

                    The issue I am having here is, on client myProperties is now treated as List<String> where I am expecting java.util.Properties which is sort of Map. Could you provide any inputs on how I can tackle this?

                     

                    Thanks for your time and help.

                    • 7. Re: EJB3 Webservice invocation failing with Unmarshalling Error
                      sfcoy

                      Now you're heading into the murky world of JAXB bindings.

                       

                      There's quite a good article at Basics of Customizing Type Mappings which is getting on a little bit, but it'll give you the general idea.