I am trying to store the javax.naming.Reference object
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");
return myRef;
}
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
object ?
Thanks,
Bijan
Discussions
EJB programming & troubleshooting: Using JNDI Reference for a non-serialized object in EJB
-
Using JNDI Reference for a non-serialized object in EJB (3 messages)
- Posted by: Bijan Mohanty
- Posted on: September 28 2001 00:47 EDT
Threaded Messages (3)
- 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
-
Using JNDI Reference for a non-serialized object in EJB[ Go to top ]
- Posted by: Mark Wilcox
- Posted on: September 29 2001 14:48 EDT
- in response to Bijan Mohanty
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.
Mark -
Using JNDI Reference for a non-serialized object in EJB[ Go to top ]
- Posted by: Mr Hunj
- Posted on: September 29 2001 20:57 EDT
- in response to Mark Wilcox
You should impl an ObjectFacotry to do this. -
Using JNDI Reference for a non-serialized object in EJB[ Go to top ]
- Posted by: Bijan Mohanty
- Posted on: October 01 2001 16:57 EDT
- in response to Mark Wilcox
Hi Mark,
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 ?
TIA
Bijan