getHandle() of EJBObject does not work


EJB programming & troubleshooting: getHandle() of EJBObject does not work

  1. getHandle() of EJBObject does not work (1 messages)

    I am using Tomcat5.0 and JBoss4.0.2 for my application. Both JBoss and Tomcat are clustered. There are several Stateful Session Beans used in the application. So in order for the clients (delegates on Tomcat) to maintain a serializable SFSB state across nodes I use the Handle. But when I use EJBObject directly I have no problem but when I use Handle to get the EJBObject then I get NameNotFoundException - Somebody please help!!!
    Following is the sample JSP that I have been trying to test
    ... .... protected String getId(EJBObject session) { try { Handle handle = session.getHandle(); ByteArrayOutputStream fo = new ByteArrayOutputStream(); ObjectOutputStream so = new ObjectOutputStream(fo); so.writeObject(handle); so.flush(); so.close(); return new String(fo.toByteArray()); } catch(RemoteException ex) { ex.printStackTrace(); } catch(IOException ex) { ex.printStackTrace(); } return null; } public EJBObject getService(String id) { try { byte[] bytes = new String(id).getBytes(); InputStream io = new ByteArrayInputStream(bytes); ObjectInputStream os = new ObjectInputStream(io); Handle handle = (Handle) os.readObject(); os.close(); EJBObject obj = (EJBObject) handle.getEJBObject(); return (obj); } catch(Exception ex) { ex.printStackTrace(); } return null; } .... .... In the above example EJBObject that goes into getId() is working just fine. But the same EJBObject after getService() call throws NameNotFoundException
    Following is the properties for getting the EJB
    PROVIDER_URL=jnp://jboss1:1100, jboss2:1100
    Somebody please help if you could think of any reason.
    Thanks a lot
  2. Hello All, We found a solution ourselves. A colleague of mine found that INITIAL_CONTEXT_FACTORY should be org.jboss.naming.NamingContextFactory which is JBoss Specific. When I changed that it worked without any error message. Thanks