[jboss-user] [EJB 3.0] - ClassCastException after JNDI lookup

tperrigo do-not-reply at jboss.com
Fri Oct 31 14:21:54 EDT 2008


I've got a very simple stateless session bean:


  | @Stateless
  | @Remote(ProcessAdminRemote.class)
  | public class ProcessAdminEJB implements ProcessAdmin {
  | ...
  | }
  | 

...with the following business and Remote interfaces (no local interface):

  | public interface ProcessAdmin {
  | ...
  | }
  | 
  | public interface ProcessAdminRemote extends ProcessAdmin {
  | }
  | 
  | 

Everything seems to deploy just fine, but when I try to do the following JNDI lookup, I get a ClassCastException:


  | InitialContext ctx = new InitialContext();
  | final String jndiName = "ProcessAdminEJB/remote";
  | Object o  = ctx.lookup(jndiName);
  | if ( o == null ) {
  | 	System.err.println("unable to find " + jndiName);
  | } else {
  | 	System.out.println("retrieved instance of "+o.getClass().getName());
  | }
  | // the following line causes the ClassCastException...
  | ProcessAdmin ejb = (ProcessAdmin)o;
  | 

When I print out the name of the instance returned by the JNDI lookup, I find that it is an instance of javax.naming.Reference.  

I really have no idea what I'm doing wrong...I've found a couple example EJB3 stateless session beans, and they are pretty much exactly the same as my setup.  I'm using JBossAS 5.0.0.CR2.  This is driving me nuts...any help would be extremely appreciated!

Thanks in advance,
Tim



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4186100#4186100

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4186100



More information about the jboss-user mailing list