2

In OSB(Oracle Service Bus), I used the default report action, but disabled the default reporting provider in the console settings, so no one is reading the message from the default reporting message queue.

Now I am trying to use a JMS adapter in OEP(Oracle Event Processing) to get the reporting message from the default reporting queue.

I got the message and it is an Object Message(com.bea.wli.reporting.jmsprovider.runtime.ReportMessage), while testing I can only display the messageId by calling objectMessage.getJMSMessageID(), but when I can call objectMessage.getObject() I get this exception in the OEP server console. The code throws the exception is not visible to me. Here is the exception I am getting:

java.lang.RuntimeException: java.lang.ClassCastException: cannot assign instance of org.apache.xmlbeans.impl.values.XmlAnyTypeImpl 
to field com.bea.wli.reporting.jmsprovider.runtime.ReportMessage.metadata 
of type org.apache.xmlbeans.XmlObject in instance of com.bea.wli.reporting.jmsprovider.runtime.ReportMessage

But the Javadoc shows this XmlAnyTypeImpl implements XmlOjbect

package org.apache.xmlbeans.impl.values;

import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.SchemaType;  

public class XmlAnyTypeImpl extends XmlComplexContentImpl implements XmlObject

My understanding about this exception is :

  • I have a Interface A, and a class B implements A
  • now I have a "b" which is a instance of B
  • this exception is saying that I can not assign "b" to a variable which type is A.

Is this correct?

If my understanding is correct, how could this happen... Some people on the internet saying it could be these are not loaded in the same class loader, I am not quite sure is there a way that I can control that?

I have already tried to put this getObject call in a separate OSGi bundle to see if that would force it to use one classloader, but I am still getting the same exception.

Tech Noob
  • 510
  • 1
  • 9
  • 33
  • 1
    Are you sure that the `XMLObject` being implemented by `XmlAnyTypeImpl` is the same one as `org.apache.xmlbeans.XmlObject` ? If the same name applies to two different classes with the same name in different packages this could occur. With a generic name like "XmlObject" its not impossible, – Sled Dec 10 '15 at 16:12
  • 1
    add imports also to the question.. it seems they are interfaces with same names but different packages – awsome Dec 10 '15 at 16:16
  • I just added the import part, this is from the java doc, I downloaded this xmlbeans jar, I will not be able to change it. – Tech Noob Dec 10 '15 at 16:31
  • This can happen if the interface and implementation come from different class loaders. This is a subtler version of the "cannot cast X to X" problem. – Jim Garrison Dec 10 '15 at 17:02
  • @JimGarrison Is there anyway I can could find out how the classes are loaded, and force them to load in the same class loader? Thank you. – Tech Noob Dec 10 '15 at 17:26

0 Answers0