Note that there are some explanatory texts on larger screens.

plurals
  1. POClassCastException When Calling an EJB Remotely that Exists on Same Server
    text
    copied!<p>I have 2 ejbs. Ejb-A that calls Ejb-B. They are not in the same Ear. </p> <p>For portability Ejb-B may or may not exist on the same server. (There is an external property file that has the provider URLs of Ejb-B. I have no control over this.) </p> <p>Example Code: in Ejb-A</p> <pre><code>EjbBDelegate delegateB = EjbBDelegateHelper.getRemoteDelegate(); // lookup from list of URLs from props... BookOfMagic bom = delegateB.getSomethingInteresting(); </code></pre> <hr> <p><strong>Use Cases/Outcomes</strong>:</p> <ol> <li>When Ejb-B <strong>DOES NOT EXIST</strong> on the same server as Ejb-A, everything works correctly. (it round-robbins through the URLs)</li> <li>When Ejb-B <strong>DOES EXIST</strong> on the same server, and Ejb-A happens to call Ejb-B on the same server, everything works correctly.</li> <li>When Ejb-B <strong>DOES EXIST</strong> on the same server, and Ejb-A calls Ejb-B on a different server, I get:</li> </ol> <blockquote> <p>javax.ejb.EJBException: nested exception is: java.lang.ClassCastException: $Proxy126 java.lang.ClassCastException: $Proxy126</p> </blockquote> <p>I'm using Weblogic 10.0, Java 5, EJB3</p> <p>Basically, if Ejb-B Exists on the server, it must be called ONLY on that server. </p> <p>Which leads me to believe that the class is getting loaded by a local classloader (on deployment?), then when called remotely, a different classloader is loading it. (causing the Exception) But it should work, as it should be Serialized into the destination classloader...</p> <p>What am I doing wrong?? </p> <p>Also, when reproducing this locally, Ejb-A would favor the Ejb-B on the same server, so it was difficult to reproduce. But this wasn't the case on other machines.</p> <p>NOTE: This all worked correctly for EJB2</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload