title: JAX-WS 2.1 - Why do I get a 'MessageCreationException' while trying to process my first web service request?
body: <p>I am using JAX-WS 2.1 and I have built a web service using JAX-WS via the development tools in Netbeans 6.0.  It seems that everything builds correctly and starts correctly, however on the first web service request after restarting Tomcat, I get the following exception:</p>
  
  <p>SEVERE: Couldn't create SOAP message due to exception: Unable to create StAX reader or writer
  com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: Unable to create StAX reader or writer
          at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:365)
          at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:277)
          at com.sun.xml.ws.transport.http.HttpAdapter.access$500(HttpAdapter.java:93)
          at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:457)
          at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
          at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
          at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129)
          at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160)
          at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
          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.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
          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:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
          at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
          at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
          at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
          at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
          at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
          at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
          at java.lang.Thread.run(Thread.java:619)</p>
  
  <p>I imagine someone has seen this error before, can anyone tell me what I am doing wrong and why I am only getting it on the initial web service request?</p>
  
  <p>Soap request:</p>
  
  <pre><code>&lt;soapenv:Envelope 
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:xsd="ws.companynamehere.com/xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:ns2="ws.companynamehere.com/xsd"&gt;
  &lt;soapenv:Header/&gt;
  &lt;soapenv:Body&gt;
      &lt;ns2:Pickup&gt;
          &lt;contact&gt;
              &lt;company&gt;DEMO COMPANY&lt;/company&gt; 
              &lt;name&gt;DEMO COMPANY&lt;/name&gt; 
              &lt;phone&gt;1111111111&lt;/phone&gt; 
              &lt;email&gt;test@test.com&lt;/email&gt; 
          &lt;/contact&gt;
          &lt;shipper&gt;
              &lt;shipperName&gt;DEMO&lt;/shipperName&gt;
              &lt;address&gt;123 TEST AVE&lt;/address&gt; 
              &lt;city&gt;SOMEWHERE&lt;/city&gt; 
              &lt;state&gt;SC&lt;/state&gt; 
              &lt;zip&gt;99999&lt;/zip&gt; 
              &lt;pickupContactName&gt;Test&lt;/pickupContactName&gt; 
              &lt;phone&gt;9999999999&lt;/phone&gt; 
              &lt;email&gt;test@test.com&lt;/email&gt; 
              &lt;email2 /&gt; 
              &lt;email3 /&gt; 
              &lt;fax  /&gt; 
              &lt;requestPickupDate&gt;20101008&lt;/requestPickupDate&gt; 
              &lt;requestPickupTime&gt;1200&lt;/requestPickupTime&gt;  
          &lt;/shipper&gt;
          &lt;consignees&gt;
              &lt;Consignee&gt;
                  &lt;name&gt;TEST&lt;/name&gt; 
                  &lt;destZip&gt;99999&lt;/destZip&gt; 
                  &lt;weight&gt;1234&lt;/weight&gt; 
                  &lt;pieces&gt;1&lt;/pieces&gt; 
                  &lt;pkgType&gt;PL&lt;/pkgType&gt; 
              &lt;/Consignee&gt;
          &lt;/consignees&gt;
      &lt;/ns2:Pickup&gt;
  &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Soap response (1st try only):</p>
  
  <pre><code>&lt;S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;S:Body&gt;
        &lt;S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"&gt;
           &lt;faultcode&gt;S:Client&lt;/faultcode&gt;
           &lt;faultstring&gt;Couldn't create SOAP message due to exception: Unable to create StAX reader or writer&lt;/faultstring&gt;
        &lt;/S:Fault&gt;
     &lt;/S:Body&gt;
  &lt;/S:Envelope&gt;
  </code></pre>