[jboss-user] [JNDI/Naming/Network] - Binding and Saving Objects

inyourcorner do-not-reply at jboss.com
Mon Jan 22 16:48:01 EST 2007


Hi all - looking for a bit of help or direction.

I'm having a bit of a problem trying to bind an Object-type implementing Referenceable to JNDI.  There's a requirement here that the object can't be saved in a Serialized way, it needs to be a reference so it's kept alive in memory even after I've disconnected to it.

Hopefully someone can help - i've tried to lay it out below as simply as I can.

-> I've got an Object-Type that implements Referenceable (I've implemented the getReference() function appropriately I hope:
	
public Reference getReference(){
  | 
  |   // the ObjectTreeRefAddr is a class I wrote implementing RefAddr 
  |   // so that I can store away a whole "live" object, and not just String props
  |   ObjectTreeRefAddr refAddr = new ObjectTreeRefAddr("objecttree", this);
  |   Reference myRef = new Reference(ObjectTree.class.getName(), 
  |                                     refAddr, 
  |                                     ObjectTreeFactory.class.getName(), null);	
  |    // debug-code, below will return the Reference correctly
  |    ObjectTreeRefAddr newRefAddr = (ObjectTreeRefAddr)myRef.get(0);
  |    
  |    return myRef;
  | }

I've also created the Factory for this ObjectTree class but the problem i'm having is when I go to Bind(), not really at the Lookup part yet.  

// Following code breaks...
  | context.bind("objecttree", myObj);
  | 
  | // ...With the following error:
  | /* Problem binding: 
  | javax.naming.CommunicationException [Root exception is java.rmi.MarshalException: error marshalling arguments; nested exception is: 
  | 	java.io.NotSerializableException: com.company.work.ObjectTree]
  | */
I think (hope) i'm doing this correctly - it binds just fine if I use a StringRefAddr instead of trying to bind the Object Reference.  I'm also hoping that this is even possible.  Again it's got to be a Referenceable and not a Serializable (a forced decision).

Thanks, in advance, to anyone that could offer suggestions.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4005011#4005011

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4005011



More information about the jboss-user mailing list