Class cast exception due to overloaded use of a constant
--------------------------------------------------------

                 Key: AXIS2-2147
                 URL: https://issues.apache.org/jira/browse/AXIS2-2147
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
          Components: kernel
            Reporter: Matt Lovett


When using Sandesha, messages may be retransmitted. When running the unit tests 
that exercise this, we are getting a 
class cast exception the second time that we send a message. Here's the java 
stack trace:

10943 [Axis2 Task] ERROR org.apache.sandesha2.workers.SenderWorker  - Sandesha2 
got an exception when sending a message: java.lang.ClassCastException: 
org.apache.commons.httpclient.methods.PostMethod incompatible with 
java.lang.String.
java.lang.ClassCastException: org.apache.commons.httpclient.methods.PostMethod 
incompatible with java.lang.String
        at 
org.apache.axis2.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:48)
        at 
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:349)
        at 
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:208)
        at org.apache.axis2.engine.AxisEngine.resumeSend(AxisEngine.java:383)
        at org.apache.sandesha2.workers.SenderWorker.run(SenderWorker.java:228)
        at 
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
        at 
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:788)

The code that is executing is the cast to String of 'httpMethod'

    public void send(MessageContext msgContext, OMElement dataout, URL url, 
String soapActionString)
            throws MalformedURLException, AxisFault, IOException {
        // execute the HtttpMethodBase - a connection manager can be given for
        // handle multiple

        String httpMethod =
                (String) 
msgContext.getProperty(Constants.Configuration.HTTP_METHOD);

        if ((httpMethod != null)
                && 
Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
            this.sendViaGet(msgContext, url, soapActionString);

            return;
        }
        this.sendViaPost(msgContext, dataout, url, soapActionString);
    }


I think the root cause is probably due to two contstants having the same value, 
and both being used as keys into the MessageContext properties:

org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD = "HTTP_METHOD"
and
org.apache.axis2.Constants.Configuration.HTTP_METHOD = "HTTP_METHOD"

I think that the HTTPConstants one is written part way through the first send, 
making a side-effect that poisons the second send. This is when using Sandesha 
without calling the MessageContext serialization code, persumably if we were 
using that we would avoid the issue.





-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to