Uploaded image for project: 'Axis'
  1. Axis
  2. AXIS-2775

ClassCastException in org.apache.axis.Message.setup()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2
    • None
    • Basic Architecture
    • None
    • Windows, Weblogic Server 10.0 MP1

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            wattazoum Oumar Aziz OUATTARA
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: