Search code examples
jakarta-eeejbjndi

jndi lookup routine?


I've got a java se aplication that lookup for remote bean and executes methods of this object. Is there a way to lookup just once and then use this object or i have to lookup every time ?

I was trying to make it public object for class but when i call ive got an error.

public class AttendanceRegisterClient {
public static StudentBeanRemote remoteObj;
...
ArrayList<Student> listaStudentow = AttendanceRegisterClient.remoteObj.listaStudentow();

The Error

Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:AttendanceRegisterBean,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@53511634

if i call jndi lookup again it works but i dont want to do it all the time. Is there a way to pass around this object ?


Solution

  • Answer Updated:

    Your Question: Is there a way to lookup remote object just once and then use this object in the client every time, without re-doing the lookup ?

    Answer: Yes, its possible through Service Locator Pattern. This article describes top to bottom including examples. >> http://www.oracle.com/technetwork/java/servicelocator-137181.html