| Author |
Newcomer to EJB facing problems
|
baba mama
Greenhorn
Joined: Jun 23, 2005
Posts: 4
|
|
Hello all! I am new to EJBs and I tried to follow a tutorial released by Borland on how using EJBs with JBuilderX and JBoss 3.2 I succeeded creating a simple session bean and test it. But when I try to create an entity bean accessed by a session bean, in testing with a EJB test client I get the following: -------------------------------------------------------------------------- -- Initializing bean access. -- Succeeded initializing bean access through Home interface. -- Execution time: 941 ms. -- Calling create() -- Succeeded: create() -- Execution time: 171 ms. -- Return value from create(): EmployeeSes:Stateless. -- Calling getEmpName(4) -- Succeeded: getEmpName(4) -- Execution time: 320 ms. -- Return value from getEmpName(4): name not found. ------------------------------------------------------------------ Apparently, everything goes fine except the output desired. The DataSource used is employee.jds from the samples given within Jbuilder and the tutorial explains how to define JNDI stuff. The entity bean used is created visually from the table EMPLOYEE the session bean has a local reference to the entity bean and a method public String getEmpName(Short empNo) { String empName = "name not found"; try { javax.naming.Context context = new javax.naming.InitialContext(); Object object = context.lookup("java:comp/env/ejb/Employee"); EmployeeHome empHome = (EmployeeHome) javax.rmi.PortableRemoteObject.narrow(object, EmployeeHome.class); Employee emp = empHome.findByPrimaryKey(empNo); empName = emp.getFirstName() + " " + emp.getLastName(); } catch (NamingException ex) { ex.printStackTrace(); } catch (ClassCastException ex) { ex.printStackTrace(); } catch (Exception ex){ ex.printStackTrace(); } return empName; } and the test client ejb calls in its main client.create() and client.getEmpName(new Short ("4") I am really out of inspiration !!! Can anyone help me ?
|
 |
 |
|
|
subject: Newcomer to EJB facing problems
|
|
|