storing remote objects using JNDI


EJB programming & troubleshooting: storing remote objects using JNDI

  1. storing remote objects using JNDI (4 messages)


    I have some code that looks like the below line

    authMgmrRemote = authMgmrHome .create();

    Home object I am getting like ..

    authMgmrHome = (AuthenticationMgmrHome)JNDIHelper.lookup(Resources.getInstance().getInitialContext(),"AuthenticationMgmr",AuthenticationMgmrHome.class);

    which is fine.

    But I want to store the authMgmrRemote (with some name) in the Naming service and get it using the same from a RMI client.

    I feel like it is possible. becoz right now I am getting home (like above) and creating the remote object from it in my RMI.

    But I am not much familiar with EJB and jNDI. Home objects are maintained by Websphere Container. But I dont know how to bind the remote objects dynamically.

    If anyone did this already, Can you please post the code snippet.

    Thanks in advance

    Threaded Messages (4)

  2. storing remote objects using JNDI[ Go to top ]

    I don't think it is possible to store the remote object using JNDI. As far as I understand the remote object's will be created when you call the create method of the home interface. Doesn't mean that a new bean is always created, you might get one from the pool depending upon the type of bean that you are using. However once you get the remote object reference you might persist the handle of the remote object. The only issue with this is that your reference is valid as long as your bean instance is present in the app server. If the app server has removed your bean instance because of the time out parameter then accessing the remote object will raise an exception.

    Hope this is what you were looking for.
  3. storing remote objects using JNDI[ Go to top ]

    I don't understand why it should not work. Of course, I am not an EJB expert by any means, so could someone explain this to me?

    My reasoning is as follows (I am assuming stateless sessionbeans throughout):

    Suppose I have an EJB, say AnEJB (very creative!) and a client program which is a Java application running outside the EJB container. It looks up AnEJB through standard JNDI sequence: JndiInitialContext -> AnEJBHome -> AnEJBRemote.

    The client can hold on to AnEJBRemote as long as it wants, and it is totally transparent whether the container keeps the same instance of AnEJB all the time or throws out the original and creates a new one.

    Now suppose the client itself is an EJB, say ClientEJB. Things should work exactly as before, except for the fact that ClientEJB will lose its AnEJBRemote reference whenever the container swaps out the original ClientEJB instance and brings in a new one.

    So, ClientEJB decides to persist the AnEJBRemote reference. It can do that in JNDI, or maybe even some other database. All that has happened is that the AnEJBRemote has been serialized and persisted, instead of being kept in memory. Will that cause a problem?

  4. storing remote objects using JNDI[ Go to top ]

    Hi Can u tell me how to store the handle. i have got the handle from the remote, but now i wanna store it, how do i do it ? do i need to serialize and store it or.. if possible some one can give me the code.
    And i have one dought : when exactly the server will create the instances of the bean. like we can specify the max no of beans for every bean, suppose if i say 10 then when all the 10 instances will be created. when the first client looksup or when the server comes up ? can some one explain me.

    Thanks in advance.
  5. storing remote objects using JNDI[ Go to top ]

    If you want to use the same EJB instance, in your next call, with out locating once again, better get the handle of that EJB object, from that handle, get the reference to that EJB.(You need not lookup again).

    Storing EJB handle?its upto you. If it is a HTTP client, you can keep this in Http Session.