problem calling enity bean from session bean

Created enterprise app with web and ejb modules.

Created a CMP Entity Bean with local interface.

Created session bean with a remote interface, then used the process: enterprise resources> call enterprisebeans to generate lookup code for the entity bean.

Tried using the session bean from the web modules jsp page and an exception is thrown with message No object bound to 'Table1Bean'

public Object getEntry(final String ID){

entity.Table1Local lo =null;

entity.Table1LocalHome lh =null;

try{

/////////////////////NEXT LINE THROWS AN EXCEPTION/////////////////////////////////////

lh = lookupTable1Bean();

}catch (javax.naming.NamingException ex){

// ... code to handle exception

}

try{

lo = lh.findById(ID);

}

catch(javax.ejb.FinderException ex){

// ... code to handle exception

}

return lo;

}

private entity.Table1LocalHome lookupTable1Bean()throws javax.naming.NamingException{

javax.naming.Context c =new javax.naming.InitialContext();

entity.Table1LocalHome rv = (entity.Table1LocalHome) c.lookup("java:comp/env/ejb/Table1Bean");

return rv;

}

[2081 byte] By [poshjosha] at [2007-11-26 21:09:17]
# 1

try to load remote interface as shown below:

try {

InitialContext ic = new InitialContext();

Object objRef = ic.lookup("java:comp/env/ejb/Table1");

Table1Home home =(Table1Home)PortableRemoteObject.narrow(objRef,Table1Home.class);

table = home.create();

} catch (RemoteException ex) {

// ... code to handle exception

}

Read more in chapters 23-30 of the J2EE 1.4 Tutorial:

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/

And there is web client example in Getting Started with Enterprise Beans -> Coding the Web Client chapter:

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/EJB5.html#wp79985

Jin_Ba at 2007-7-10 2:45:12 > top of Java-index,Development Tools,Java Tools...
# 2

friend,

you should add ejb ref to the session bean.

to add ref to session bean go to the visual editor of ejb-jar.xml in java studio enterprise edition (ver 8.0) and under Bean Envioroment->Enterprise Bean References click Add. select entity bean from dialog box, click ok

Message was edited by:

arunmoyal

arunmoyala at 2007-7-10 2:45:12 > top of Java-index,Development Tools,Java Tools...