Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Name comp/ejb not found

 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get an error "javax.naming.NameNotFoundException: Name comp/ejb not found in context "java:" when I do a lookup. Why would java:comp/ejb not be available?

package sessions;

import java.math.BigDecimal;

import javax.ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import entities.ora9EmpLocal;
import entities.ora9EmpLocalHome;
/**
* Bean implementation class for Enterprise Bean: Session1
*/
public class Session1Bean implements javax.ejb.SessionBean {
private javax.ejb.SessionContext mySessionCtx;
/**
* getSessionContext
*/

public void runOra9Emp(int empno){
String jndiName = "java:comp/ejb/ora9EmpLocalHome";
ora9EmpLocalHome oh;
ora9EmpLocal ol;

try {
InitialContext initialContext = new InitialContext();

Object homeObject = initialContext.lookup(jndiName);
oh = (ora9EmpLocalHome) homeObject;
ol = oh.create(new BigDecimal(1000));
ol.setEname("Lalala");
} catch (NamingException e) {

e.printStackTrace();
}catch (CreateException e) {

e.printStackTrace();
}




}


public javax.ejb.SessionContext getSessionContext() {
return mySessionCtx;
}
/**
* setSessionContext
*/
public void setSessionContext(javax.ejb.SessionContext ctx) {
mySessionCtx = ctx;
}
/**
* ejbCreate
*/
public void ejbCreate() throws javax.ejb.CreateException {
}
/**
* ejbActivate
*/
public void ejbActivate() {
}
/**
* ejbPassivate
*/
public void ejbPassivate() {
}
/**
* ejbRemove
*/
public void ejbRemove() {
}
}
 
Sreenivasa Majji
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checking the JNDI name in your app server.

In web logic you can check this under your server name, view JNDI tree.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Burke,

Try java:comp/env/ejb.
Regards.
 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this...
java:comp/env/ejb/ora9EmpLocalHome

I get "java:comp/env/ejb/ora9EmpLocalHome is not found"

Is there a way to specify what namespace to look for a jndi name?
[ April 27, 2005: Message edited by: M Burke ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic