ClassCastException in org.apache.axis.Message.setup() -----------------------------------------------------
Key: AXIS-2775 URL: https://issues.apache.org/jira/browse/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(Message.java:344) at org.apache.axis.Message.(Message.java:246) at org.apache.axis.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:54) at test.TestBean.testingMethod(TestBean.java:38) In fact the bug has been noticed on an old axis but it's still on the svn trunk : <quotes> attachImpl = ClassUtils.forName(attachImpName); .... Constructor attachImplConstr = attachImpl.getConstructors()[0]; try { mAttachments = (Attachments) attachImplConstr.newInstance( new Object[] { initialContents, contentType, contentLocation}); .... </quotes> 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 ( http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Proxy.html ). Using this class should easily solve the issue. Best Regards wattazoum -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.