You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Christian Schlichtherle <ch...@schlichtherle.de> on 2013/08/27 16:05:10 UTC

ClassCastException after JNDI-lookup

Hi,

I am deploying an EAR and a WAR into TomEE+ 1.5.2. The EAR provides a stateful session bean with a @Local business interface because lookup from another JVM does make no sense.

The WAR should lookup the local EJB, but it should have no dependencies on Java EE APIs, so I have to use JNDI.

Now the actual JNDI-lookup using the "java:global/..." namespace works, however I get a ClassCastException as soon as I cast the proxy object to my local business interface.

I have checked that the business interface and the proxy class are loaded from different class loaders, so I thought I should try a @Remote business interface, but the issue persists.

Next, I tried to use PortableRemoteObject.narrow(), but the issue still persists.

What do I have to do to make this work or is this just another bug?

Regards,
Christian Schlichtherle


Re: ClassCastException after JNDI-lookup

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

did you check the API is correctly shared (classloading rules) between the
ear and the war?

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/8/27 Christian Schlichtherle <ch...@schlichtherle.de>

> Hi,
>
> I am deploying an EAR and a WAR into TomEE+ 1.5.2. The EAR provides a
> stateful session bean with a @Local business interface because lookup from
> another JVM does make no sense.
>
> The WAR should lookup the local EJB, but it should have no dependencies on
> Java EE APIs, so I have to use JNDI.
>
> Now the actual JNDI-lookup using the "java:global/..." namespace works,
> however I get a ClassCastException as soon as I cast the proxy object to my
> local business interface.
>
> I have checked that the business interface and the proxy class are loaded
> from different class loaders, so I thought I should try a @Remote business
> interface, but the issue persists.
>
> Next, I tried to use PortableRemoteObject.narrow(), but the issue still
> persists.
>
> What do I have to do to make this work or is this just another bug?
>
> Regards,
> Christian Schlichtherle
>
>