axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oumar Aziz OUATTARA (JIRA)" <>
Subject [jira] Created: (AXIS-2775) ClassCastException in org.apache.axis.Message.setup()
Date Wed, 04 Feb 2009 09:23:59 GMT
ClassCastException in org.apache.axis.Message.setup()

                 Key: AXIS-2775
             Project: Axis
          Issue Type: Bug
          Components: Basic Architecture
    Affects Versions: 1.2
         Environment: Windows, Weblogic Server 10.0 MP1
            Reporter: Oumar Aziz OUATTARA

There is a class cast exception in this Class of Axis when casting to "Attachments". 

java.lang.ClassCastException: org.apache.axis.attachments.AttachmentsImpl
at org.apache.axis.Message.setup(
at org.apache.axis.Message.(
at org.apache.axis.soap.MessageFactoryImpl.createMessage(
at test.TestBean.testingMethod(

In fact the bug has been noticed on an old axis but it's still on the svn trunk :

attachImpl = ClassUtils.forName(attachImpName);
Constructor attachImplConstr = attachImpl.getConstructors()[0];
            try {
                mAttachments = (Attachments) attachImplConstr.newInstance(
                        new Object[] { initialContents,
                                       contentType, contentLocation});

The ClassUtils class is using dynamic classloading. and implements it well. The problem is,
using this mechanism, you can retrieve a Class object that doesn't come from the current class
loader. Then casting to Attachments, will try to cast to a Class from a different class loader.

To handle such a case, the JDK included a class called Proxy (
). Using this class should easily solve the issue.

Best Regards

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

View raw message