[jbossws-issues] [JBoss JIRA] Updated: (JBWS-2746) ClassCastException because SOAPEnvelopeImpl blindly casts to o.j.ws.core.soap.SOAPElementImpl

Alessio Soldano (JIRA) jira-events at lists.jboss.org
Mon Nov 9 04:54:05 EST 2009


     [ https://jira.jboss.org/jira/browse/JBWS-2746?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alessio Soldano updated JBWS-2746:
----------------------------------

    Fix Version/s:  jbossws-native-3.2.2
         Priority: Major  (was: Critical)


> ClassCastException because SOAPEnvelopeImpl blindly casts to o.j.ws.core.soap.SOAPElementImpl
> ---------------------------------------------------------------------------------------------
>
>                 Key: JBWS-2746
>                 URL: https://jira.jboss.org/jira/browse/JBWS-2746
>             Project: JBoss Web Services
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: jbossws-native
>    Affects Versions: jbossws-native-3.2.0
>         Environment: Windows Vista Ultimate, java6, Axis2
>            Reporter: Jürgen Hoffmann
>            Assignee: Alessio Soldano
>             Fix For:  jbossws-native-3.2.2
>
>
> Recently I've started working with JBoss, and I think I've located a problem in JBossWS.
> The constructor of org.jboss.ws.core.soap.SOAPEnvelopeImpl blindly casts a given implementation of javax.xml.soap.SOAPElement to org.jboss.ws.core.soap.SOAPElementImpl, which results in a ClassCastException in the application I'm working on.
> public SOAPEnvelopeImpl(SOAPPartImpl soapPart, SOAPElement element, boolean addHeaderAndBody) throws SOAPException
> {
>     super((SOAPElementImpl)element);
> This constructor is used in org.jboss.ws.core.soap.EnvelopeBuilderDOM:
> SOAPEnvelopeImpl soapEnv = new SOAPEnvelopeImpl(soapPart, soapFactory.createElement(domEnv, false), false);
> The Method org.jboss.ws.core.soap.SOAPFactoryImpl.createElement(Element,boolean) does not necessarily return an instance of org.jboss.ws.core.soap.SOAPElementImpl, but might return any other class which implements javax.xml.soap.SOAPElement, because it does not use its own method createElement(String,String,String) to create the SOAPElement, but rather obtains a different Object which also extends javax.xml.soap.SOAPFactory and delegated to that other subclass of javax.xml.soap.SOAPFactory.
> SOAPFactory factory = SOAPFactory.newInstance();
> SOAPElement soapElement = factory.createElement(localName, prefix, nsURI);
> I don't understand why this is done in a non-static method of a class which also extends SOAPFactory. Wouldn't it be better so simply do the following?
> SOAPElement soapElement = this.createElement(localName, prefix, nsURI);
> This would return new SOAPElementImpl(localName, prefix, uri) and the cast in SOAPEnvelopeImpl would work.
> Otherwise SOAPEnvelopeImpl would have to be modified to handle other implemetations of javax.xml.soap.SOAPElement, which might be more complicated.
> In the specific case where I stumbled over this problem the exception was:
> java.lang.ClassCastException: org.apache.axis2.saaj.SOAPElementImpl cannot be cast to org.jboss.ws.core.soap.SOAPElementImpl
>         at org.jboss.ws.core.soap.SOAPEnvelopeImpl.<init>(SOAPEnvelopeImpl.java:57)
> The application includes modules which use Axis2 as a SOAP client. JARs includes with the application always appear in the classpath before JBossWS.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jbossws-issues mailing list