1 Reply Latest reply: Feb 28, 2011 2:58 PM by Sat Ena RSS

Sporadic error sending SOAP messages : java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden"

Sat Ena Newbie

Hi,

 

I am facing a sporadic (intermittent) issue when tried to send SOAP messages over HTTPS through a proxy. Below are the checks done

 

- SSL certificates installed.

- WebService end-point is always avaliable. No issue with it.

- When the failed messages are re-sent they go through fine.

- Connected through a proxy server.

- Using SAAJ api provided by Jboss installation

     /server/default/lib/saaj-api.jar

     /server/default/lib/saaj-impl.jar

- Java version: jdk1.5.0_11

- Jboss version: jboss-4.0.5.GA

 

Code Snippet of client which sends the SOAP message:

-----------------------------------------------------------------------------------

private String sendSoap(String content) throws IOException

    {

        String retValue = "";

        try {

            String methodName = this.properties.getProperty ("method");

            String url = this.properties.getProperty ("url");

            String soapAction = this.properties.getProperty ("action");

            if (soapAction==null) soapAction = "DEFAULT";

            String nameSpace = this.properties.getProperty (methodName+".namespace");

            String parameter = this.properties.getProperty (methodName+".parameter");

 

            javax.xml.soap.SOAPMessage message = javax.xml.soap.MessageFactory.newInstance().createMessage();

            message.getMimeHeaders().addHeader("SOAPAction",soapAction);

            javax.xml.soap.SOAPHeader header = message.getSOAPHeader();

            javax.xml.soap.SOAPBody body = message.getSOAPBody();

            javax.xml.soap.SOAPFactory soapFactory = javax.xml.soap.SOAPFactory.newInstance();

            javax.xml.soap.Name bodyName = soapFactory.createName(methodName,"ns0",nameSpace);

            javax.xml.soap.SOAPBodyElement bodyElement = body.addBodyElement(bodyName);

            javax.xml.soap.Name parameterName = soapFactory.createName (parameter);

            javax.xml.soap.SOAPElement parameterElement = soapFactory.createElement (parameterName);

            parameterElement.addTextNode (content);

            bodyElement.addChildElement (parameterElement);

            java.io.ByteArrayOutputStream out1 = new java.io.ByteArrayOutputStream();

            message.writeTo (out1);

            java.net.URL endpoint = new java.net.URL(url);

 

            javax.xml.soap.SOAPConnection conn = javax.xml.soap.SOAPConnectionFactory.newInstance().createConnection();

 

            javax.xml.soap.SOAPMessage response = conn.call(message,endpoint);

            java.io.ByteArrayOutputStream out2 = new java.io.ByteArrayOutputStream();

            response.writeTo(out2);

 

            javax.xml.soap.SOAPBody responseBody = response.getSOAPBody();

 

            org.w3c.dom.Document document = responseBody.extractContentAsDocument();

            retValue = document.getElementsByTagNameNS( nameSpace, methodName+"Return").item (0).getTextContent ();

 

       }

        catch (SOAPException ex)

        {       ex.printStackTrace();

            throw new IOException(ex.getMessage());

        }

        catch (FactoryConfigurationError ex)

        {

            ex.printStackTrace();

            throw new IOException(ex.getMessage());

        }

        return retValue;

    }

 

Error stack trace when messaged failed:

-----------------------------------------------------------

com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection post

SEVERE: SAAJ0009: Message send failed

com.sun.xml.messaging.saaj.SOAPExceptionImpl: java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:146)

     at testproj.SOAPProtocolHandler.sendSoap(SOAPProtocolHandler.java:66)

     at testproj.SOAPProtocolHandler.sendMessage(SOAPProtocolHandler.java:29)

     at testproj.SOAPProtocolHandler.sendMessage(SOAPProtocolHandler.java:33)

     at testproj.DefaultDestinationHandler.run(DefaultDestinationHandler.java:47)

     at testproj.AbsHandler.sendMessage(AbstractDestinationHandler.java:73)

     at testproj.Invoker.run(DestinationInvoker.java:73)

     at testproj.MessagingBean.onMessage(TransporterBean.java:64)

     at sun.reflect.GeneratedMethodAccessor219.invoke(Unknown Source)

     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

     at java.lang.reflect.Method.invoke(Method.java:585)

     at org.jboss.invocation.Invocation.performCall(Invocation.java:359)

     at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:495)

     at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)

     at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:116)

     at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)

     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)

     at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)

     at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)

     at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:109)

     at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)

     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)

     at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:402)

     at org.jboss.ejb.Container.invoke(Container.java:954)

     at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:987)

     at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1287)

     at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:266)

     at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:905)

     at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)

     at org.jboss.mq.SpySession.run(SpySession.java:323)

     at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)

     at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)

     at java.lang.Thread.run(Thread.java:595)

Caused by: java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed

     at java.security.AccessController.doPrivileged(Native Method)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:140)

     ... 32 more

Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:344)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:169)

     ... 34 more

Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden"

     at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:1354)

     at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:168)

     at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:861)

     at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:301)

     ... 35 more

 

CAUSE:

java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed

     at java.security.AccessController.doPrivileged(Native Method)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:140)

     at testproj.SOAPProtocolHandler.sendSoap(SOAPProtocolHandler.java:66)

     at testproj.SOAPProtocolHandler.sendMessage(SOAPProtocolHandler.java:29)

     at testproj.SOAPProtocolHandler.sendMessage(SOAPProtocolHandler.java:33)

     at testproj.DefaultDestinationHandler.run(DefaultDestinationHandler.java:47)

     at testproj.AbsHandler.sendMessage(AbstractDestinationHandler.java:73)

     at testproj.Invoker.run(DestinationInvoker.java:73)

     at testproj.MessagingBean.onMessage(TransporterBean.java:64)

     at sun.reflect.GeneratedMethodAccessor219.invoke(Unknown Source)

     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

     at java.lang.reflect.Method.invoke(Method.java:585)

     at org.jboss.invocation.Invocation.performCall(Invocation.java:359)

     at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:495)

     at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)

     at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:116)

     at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)

     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)

     at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)

     at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)

     at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:109)

     at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)

     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)

     at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:402)

     at org.jboss.ejb.Container.invoke(Container.java:954)

     at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:987)

     at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1287)

     at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:266)

     at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:905)

     at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)

     at org.jboss.mq.SpySession.run(SpySession.java:323)

     at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)

     at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)

     at java.lang.Thread.run(Thread.java:595)

Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:344)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:169)

     ... 34 more

Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden"

     at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:1354)

     at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:168)

     at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:861)

     at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:301)

     ... 35 more

 

CAUSE:

java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed

     at java.security.AccessController.doPrivileged(Native Method)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:140)

     at testproj.SOAPProtocolHandler.sendSoap(SOAPProtocolHandler.java:66)

     at testproj.SOAPProtocolHandler.sendMessage(SOAPProtocolHandler.java:29)

     at testproj.SOAPProtocolHandler.sendMessage(SOAPProtocolHandler.java:33)

     at testproj.DefaultDestinationHandler.run(DefaultDestinationHandler.java:47)

     at testproj.AbsHandler.sendMessage(AbstractDestinationHandler.java:73)

     at testproj.Invoker.run(DestinationInvoker.java:73)

     at testproj.MessagingBean.onMessage(TransporterBean.java:64)

     at sun.reflect.GeneratedMethodAccessor219.invoke(Unknown Source)

     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

     at java.lang.reflect.Method.invoke(Method.java:585)

     at org.jboss.invocation.Invocation.performCall(Invocation.java:359)

     at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:495)

     at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)

     at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:116)

     at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)

     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)

     at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)

     at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)

     at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:109)

     at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)

     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)

     at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:402)

     at org.jboss.ejb.Container.invoke(Container.java:954)

     at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:987)

     at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1287)

     at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:266)

     at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:905)

     at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)

     at org.jboss.mq.SpySession.run(SpySession.java:323)

     at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)

     at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)

     at java.lang.Thread.run(Thread.java:595)

Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Message send failed

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:344)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:169)

     ... 34 more

Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden"

     at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:1354)

     at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:168)

     at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:861)

     at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)

     at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:301)

     ... 35 more