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
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
You can not even imagine how much your post helped me .
ReplyDeleteThank you very much.
@Anonymous, good to know that my blog saved your time! Thanks for posting comments.
ReplyDeleteThis post worked for me too...
ReplyDeleteThank Sunil.
- Amit
This helped me ...thanks
ReplyDelete