title: JAXB unmarshalling exception: unexpected element when spring webservice 1.0.4
body: <p>I have written spring webservice cleint example This is working fine with springws1.5 but when running with spring ws 1.0.4 i am getting below exception. Please help me why we will get this exception and how to resolve. I need to use down version only as my spring version is 2.0.4. Please reply as soon as possible. </p>
  
  <pre><code>Unhandled exception: 
      org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: unexpected element (uri:"http://yyy.org", local:"xxxResponse"). Expected elements are &lt;{}xxx&gt;,&lt;{}xxxResponse&gt;; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"yyy.org", local:"xxxResponse"). Expected elements are &lt;{}xxx&gt;,&lt;{}xxxResponse&gt;
      Caused by: 
      javax.xml.bind.UnmarshalException: unexpected element (uri:"http://yyy.org", local:"xxxResponse"). Expected elements are &lt;{}xxx&gt;,&lt;{}xxxResponse&gt;
       at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:603)
       at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:244)
       at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:239)
       at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
       at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1009)
       at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:446)
       at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:427)
       at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:71)
       at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:137)
       at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:240)
       at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:123)
       at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:314)
       at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:297)
       at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:107)
       at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:395)
       at org.springframework.ws.support.MarshallingUtils.unmarshal(MarshallingUtils.java:62)
       at org.springframework.ws.client.core.WebServiceTemplate$2.extractData(WebServiceTemplate.java:276)
       at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:417)
       at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:265)
       at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:253)
       at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:245)
       at encompass.mtm.webservices.Code1ServiceClient.getAddressCheckResponse(Code1ServiceClient.java:24)
  </code></pre>
  
  <p>I have coded using following example
  <a href="http://justcompiled.blogspot.com/2010/11/web-service-client-with-spring-ws.html" rel="nofollow">http://justcompiled.blogspot.com/2010/11/web-service-client-with-spring-ws.html</a>
  <em>The following changes i have done:</em>
  Genereate classes using <code>wsconsume</code> batch file from jboss bin,
  I have kept jars </p>
  
  <pre><code>saaj1.3.jar, spring-ws-core-1.0.4.jar,spring-xml-1.0.4.jar
  spring-oxm-tiger-1.0.4.jar,spring-oxm-1.0.4.jar 
  </code></pre>
  
  <p>in <code>jboss/../lib</code></p>
  
  <p>Following is in my spring configuration file:</p>
  
  <pre><code>&lt;bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"&gt;
          &lt;property name="messageFactory"&gt;
              &lt;bean class="com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="test1ObjectFactory" class="test.webservices.ObjectFactory"/&gt;
      &lt;bean id="test1ServiceMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"&gt;
          &lt;property name="contextPath" value="test.webservices" /&gt;
      &lt;/bean&gt;
      &lt;bean id="test1ServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"&gt;
          &lt;constructor-arg ref="messageFactory" /&gt;
          &lt;property name="marshaller" ref="test1ServiceMarshaller"&gt;&lt;/property&gt;
          &lt;property name="unmarshaller" ref="test1ServiceMarshaller"&gt;&lt;/property&gt;
          &lt;property name="messageSender"&gt;
              &lt;bean
                  class="org.springframework.ws.transport.http.CommonsHttpMessageSender"&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
          &lt;property name="defaultUri" value="${webservice.url}" /&gt;
      &lt;/bean&gt;
      &lt;bean id="test1ServiceClient" class="test.webservices.test1ServiceClient"&gt;
          &lt;constructor-arg ref="test1ServiceTemplate"&gt;&lt;/constructor-arg&gt;
          &lt;property name="test1ObjectFactory" ref="test1ObjectFactory"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>Now i have replaced everything and place <code>webservice 1.5.0 jar</code>. Stil i am facing this problem, Previously it worked. I haven't done much chanegs. is any thing disturbed in my code? How to chesk ..How to track this. Any help is highly appreciated.
  My ObjectFactory is simple:</p>
  
  <pre><code>@XmlRegistry
  public class ObjectFactory {
  
      /**
       * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: test.webservices
       * 
       */
      public ObjectFactory() {
      }
  
      /**
       * Create an instance of {@link xxxResponse }
       * 
       */
      public XxxResponse createxxxResponse() {
          return new xxxResponse();
      }
  
      /**
       * Create an instance of {@link xxx }
       * 
       */
      public Xxx createXXX() {
          return new XXX();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Input
  Following are classlevel annotations</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {
      "xxxData"
  })
  @XmlRootElement(name = "Xxx")
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>  @ XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "", propOrder = {
          "xxxResult"
      })
      @XmlRootElement(name = "XxxResponse")
  </code></pre>