EJB programming & troubleshooting: Using JNDI Reference for a non-serialized object in EJB
I am trying to store the javax.naming.Reference object
- Posted by: Bijan Mohanty
- Posted on: September 28 2001 00:47 EDT
of a non-serializable class in the JNDI tree and retrieve
it later. Here is the step that I followed.
1. Made the class implement javax.naming.Referenceable interface.
2. Implemented the method getReference() as follows
public Reference getReference()
StringRefAddr strRefAddr = new StringRefAddr("url", "t3://localhost:7001");
Reference myRef = new Reference("NewSessionManager.BigCustomer", strRefAddr, "weblogic.jndi.WLInitialContextFactory", "t3://localhost:7001");
3. I have rebind the object to the JNDI context.
4. To retrieve the object I have done the following step
Reference myRef = (Reference) initial.lookup("mybigcustomer");
Now I have got the reference object. Could anybody please
help me in getting my BigCustomer object from this reference
- Using JNDI Reference for a non-serialized object in EJB by Mark Wilcox on September 29 2001 14:48 EDT
- Using JNDI Reference for a non-serialized object in EJB by Mr Hunj on September 29 2001 20:57 EDT
- Using JNDI Reference for a non-serialized object in EJB by Bijan Mohanty on October 01 2001 16:57 EDT
NewSessionManager.BigCustomer = (NewSessionManager.BigCustomer) ctx.lookup("bigcustomer");
Per the JNDI tutorial to do this via a Reference'd object you have to have a NewSessionManager.BigCustomer factory.
See http://java.sun.com/products/jndi/tutorial/objects/storing/reference.html#EXAMPLE for more info.
I also think I have an example of this in the JNDI chapter for Professional Java Server Programming 2nd edition.
You should impl an ObjectFacotry to do this.
Thanks a lot for the help. I went to the link mentioned in your post. What I understood from the post was, ObjectFactory.getObjectInstance creates a new instance
of the object(in the case of example a new fruit object orange). Is there any way, I can get the the object that I
created earlier instead of creating a totally new object
and returning it ?