News and Articles on Technology, Finance and Marketing

EJB3 Remote JNDI lookup - javax.naming.Reference cannot be cast to <Remote Interface>

Standalone Client
From a standalone client, when I was doing a remote JNDI lookup for a EJB3 remote bean, I was getting the following exception:

Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference cannot be cast to sample.SampleRemote
at sample.Client.main(Client.java:14)


Sample bean was deployed in jboss-5.1.0.GA in a remote machine and I was running the client from my local machine. Initially I was suspecting the JNDI name I was using to do the lookup(JBoss' default remote jndi: <ejb-name>/remote) but after a few hours of research, I realized the issue is with the class loader.
The client was referring client classes of JBoss 5.0.1.GA which are not compatible with JBoss client classes in 5.1.0.GA.

So, I gave class path reference to 5.1.0.GA for my client and the lookup went fine!

Web Client
You may get a ClassCastException while trying to lookup/cast your EJB3 bean, the reason is described here.

http://community.jboss.org/wiki/ClassCastExceptions
Share:

4 comments:

  1. You can not even imagine how much your post helped me .
    Thank you very much.

    ReplyDelete
  2. @Anonymous, good to know that my blog saved your time! Thanks for posting comments.

    ReplyDelete
  3. This post worked for me too...

    Thank Sunil.

    - Amit

    ReplyDelete
  4. This helped me ...thanks

    ReplyDelete

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to our feed and get articles like this delivered automatically to your feed reader? Like our Facebook Page.

About Us

About Us
We provide you the latest news on technology, finance and entertainment across the globe. Fell free to contact us for any questions or concerns.

Popular Posts

Blog Archive

Recent Posts

Definition List

Definition list
Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Lorem ipsum dolor sit amet
Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Unordered List

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  • Aliquam tincidunt mauris eu risus.
  • Vestibulum auctor dapibus neque.

Pages