title: CXF + Problem writing SAAJ model to stream
body: <p>I trying to touch some service outside with CXF 3.0.0.
  But got very strange behavior like sometimes it is working and sometimes it is failing with stacktrace attached (it can process multiple requests before failing). Request body is the same. Code for sending request is the same.</p>
  
  <p>Any advice about this?</p>
  
  <p>There are some logs attached. Left side with success, right with case when request was failed.</p>
  
  <pre><code>org.apache.cxf.binding.soap.SoapFault: Problem writing SAAJ model to stream: connect timed out
          at org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor$SAAJOutEndingInterceptor.handleMessage(SAAJOutInterceptor.java:221)
          at org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor$SAAJOutEndingInterceptor.handleMessage(SAAJOutInterceptor.java:172)
          at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
          at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
          at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
          at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
          at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
          at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
          at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:137)
          at com.sun.proxy.$Proxy157.updatePurchaseRequest(Unknown Source)
          at com.j.c.vc.mc.ICS.mCOP(ICS.java:814)
          at com.j.c.vc.mc.ICS.mCOP(ICS.java:81)
          at com.j.c.sru.PCU.updateProvider(PCU.java:164)
          at com.j.c.sru.PCU.updateControls(PCU.java:78)
          at com.j.c.sru.sruMessageReceiver.onMessage(sruMessageReceiver.java:60)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
          at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
          at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
          at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
          at com.sun.proxy.$Proxy113.onMessage(Unknown Source)
          at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719)
          at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679)
          at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649)
          at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317)
          at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255)
          at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1168)
          at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1160)
          at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1057)
          at java.lang.Thread.run(Thread.java:745)
  Caused by: com.ctc.wstx.exc.WstxIOException: connect timed out
          at com.ctc.wstx.sw.BaseNsStreamWriter.doWriteStartTag(BaseNsStreamWriter.java:621)
          at com.ctc.wstx.sw.SimpleNsStreamWriter.writeStartOrEmpty(SimpleNsStreamWriter.java:265)
          at com.ctc.wstx.sw.BaseNsStreamWriter.writeStartElement(BaseNsStreamWriter.java:317)
          at org.apache.cxf.staxutils.StaxUtils.writeStartElement(StaxUtils.java:805)
          at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:732)
          at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:696)
          at org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor$SAAJOutEndingInterceptor.handleMessage(SAAJOutInterceptor.java:212)
          ... 36 more
  Caused by: java.net.SocketTimeoutException: connect timed out
          at java.net.PlainSocketImpl.socketConnect(Native Method)
          at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
          at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
          at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
          at java.net.Socket.connect(Socket.java:589)
          at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
          at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
          at sun.net.www.http.HttpClient$1.run(HttpClient.java:484)
          at sun.net.www.http.HttpClient$1.run(HttpClient.java:482)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:481)
          at sun.net.www.http.HttpClient.openServer(HttpClient.java:522)
          at sun.net.www.protocol.https.HttpsClient.&lt;init&gt;(HttpsClient.java:264)
          at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
          at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
          at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1148)
          at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
          at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
          at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1283)
          at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1258)
          at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
          at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.setupWrappedStream(URLConnectionHTTPConduit.java:174)
          at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1302)
          at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1258)
          at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.onFirstWrite(URLConnectionHTTPConduit.java:201)
          at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:47)
          at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
          at org.apache.cxf.io.CacheAndWriteOutputStream.write(CacheAndWriteOutputStream.java:80)
          at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:51)
          at com.ctc.wstx.io.UTF8Writer.write(UTF8Writer.java:143)
          at com.ctc.wstx.sw.BufferingXmlWriter.flushBuffer(BufferingXmlWriter.java:1405)
          at com.ctc.wstx.sw.BufferingXmlWriter.fastWriteRaw(BufferingXmlWriter.java:1451)
          at com.ctc.wstx.sw.BufferingXmlWriter.writeStartTagStart(BufferingXmlWriter.java:791)
          at com.ctc.wstx.sw.BaseNsStreamWriter.doWriteStartTag(BaseNsStreamWriter.java:616)
          ... 42 more
  </code></pre>
  
  <p>Left - Success. Right - FAIL.</p>
  
  <p><a href="https://i.stack.imgur.com/6gfXk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6gfXk.png" alt="IMG_2"></a>
  <a href="https://i.stack.imgur.com/VmvPD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VmvPD.png" alt="IMG_1"></a></p>