title: Can not assign a class's instance to it's interface type
body: <p>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. </p>
  
  <p>Now I am trying to use a JMS adapter in OEP(Oracle Event Processing) to get the reporting message from the default reporting queue.</p>
  
  <p>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:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>But the Javadoc shows this <code>XmlAnyTypeImpl implements XmlOjbect</code></p>
  
  <pre><code>package org.apache.xmlbeans.impl.values;
  
  import org.apache.xmlbeans.XmlObject;
  import org.apache.xmlbeans.SchemaType;  
  
  public class XmlAnyTypeImpl extends XmlComplexContentImpl implements XmlObject
  </code></pre>
  
  <p>My understanding about this exception is :</p>
  
  <ul>
  <li>I have a Interface A, and a class B implements A</li>
  <li>now I have a "b" which is a instance of B</li>
  <li>this exception is saying that I can not assign "b" to a variable which type is A. </li>
  </ul>
  
  <p>Is this correct?</p>
  
  <p>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?</p>
  
  <p>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.</p>