I have deployed a stateless session bean EmployeeEJB in OC4J. I have tested that the servlet, which is within the same OC4J, can obtain the remote home reference to the EmployeeEJB.
But when I wrote another servlet, which is located in Apache tomcat, to obtain the remote home reference to EmployeeEJB. It fails when the program starts to lookup through JNDI. Part of exception that I got is shown as follow:
javax.naming.NamingException: Cannot create resource instance
The following shows the coding which I try to obtain the remote reference for the EJB
Hashtable env = new Hashtable();
Context context = new InitialContext(env);
Object homeObject = context.lookup("java:comp/env/EmployeeBean");
// Narrow the reference to EmployeeHome.
EmployeeHome home =
(EmployeeHome) PortableRemoteObject.narrow(homeObject, EmployeeHome.class);
// Create remote object and narrow the reference to Employee.
Employee remote =
(Employee) PortableRemoteObject.narrow(home.create(), Employee.class);
Can you know the reason why I got this exception ?