*
The moose likes EJB and other Java EE Technologies and the fly likes Newcomer to EJB facing problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Newcomer to EJB facing problems" Watch "Newcomer to EJB facing problems" New topic
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 ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Newcomer to EJB facing problems
 
Similar Threads
Need Help:How to port HashMap<String-ColmnName, ArayList-ClumnData> to Datatable for multiple colmns
accessing entity bean from session bean
INDEX PROPERTY <html:form> with nested beans
help me! stateful session bean problem
JDataStoreDS not bound error