java - EJB - Lookup failed for 'ejb/BookRequestBean' -


i new ejb, , trying "hello world" type of ejb java program. here ejb:

package dukesbookstore.ejb; @stateless(name="bookrequestbean", mappedname="ejb/bookrequestbean") @named public class bookrequestbean {     //other codes here } 

and here client:

    properties prop = new properties();     prop.put(context.initial_context_factory, "com.sun.enterprise.naming.serialinitcontextfactory");     prop.setproperty("org.omg.corba.orbinitialhost", "localhost");     prop.setproperty("org.omg.corba.orbinitialport", "3700");     try {         initialcontext ctx = new initialcontext(prop);                                       ctx.lookup("ejb/bookrequestbean");         system.out.println("ejb look-up successfull!!");     } catch (namingexception e) {         // todo auto-generated catch block         e.printstacktrace();     } 

but whenever try run, getting below exception:

javax.naming.namingexception: lookup failed 'ejb/bookrequestbean' in serialcontext[myenv={org.omg.corba.orbinitialport=3700, java.naming.factory.initial=com.sun.enterprise.naming.serialinitcontextfactory, org.omg.corba.orbinitialhost=localhost, java

i have added appserv-rt.jar , gf-client.jar, javaee.jar, still no luck. can me, missing here? usign glassfish 3.1

share|improve question
    
full stacktrace help. make sure @ : glassfish.java.net/javaee5/ejb/ejb_faq.html#pojolocalejb – lmeyer may 10 '13 @ 21:15
up vote 2 down vote accepted

in addition nice @ravitrivedi answer, here few thoughts:

  • @named annotation shouldn't used way
  • don't use both name , mappedname, glassfish enough use mappedname
  • your ejb should implement remote interface
share|improve answer
    
slight interjection. name used identify ejb whereas mappedname ejb's jndi name. mappedname vendor specific. ie: glassfish supports, websphere not. – ravi trivedi may 13 '13 @ 9:48
    
@ravitrivedi yep, that's why noted it's enough glassfish. shouldn't used if want portable applications. – miljen mikic may 13 '13 @ 9:51

there can several reasons this:

1) ejb not mapped jndi name. need check whether ejb deployed , mapped jndi name. can check server gui, server log on startup or use universal test client see if ejb mapped correctly. note, utc show remotely exposed ejbs.

2) ejb exposed local application. in case, remote call or cross application call(different ear, war...) ejb fail. in scenario, create remote interface , expose it. local interface exposes ejb local calls. remote interface exposes ejb remote or cross application calls.

3) rmi/iiop port may incorrect. can check glassfish gui or server startup log see port rmi/iiop assigned to.

note: diagnose exact problem, please post full stack trace.

share|improve answer
    
+1, answer :) – pradeep simha may 13 '13 @ 12:17
    
no worries mate, cheers ! – ravi trivedi may 13 '13 @ 14:48

adding @ravi trivedi , @miljen mikic, if using glassfish, should check how ejb registered in jndi. in glassfish example type following command:

 asadmin list-jndi-entries 
share|improve answer

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments