Have you tried listing the initial context?
The jndiName is "ValidatorFactory" defined like ValidatorFactory in user-service.xml.
I use the following code to list and got NamingEnumeration which include the information like "ValidatorFactory: java.util.HashMap". But I still get null from lookup("ValidatorFactory").
Any others I need to consider?
NamingEnumeration e = initial.list("");
System.out.println("e=" + e.next());
Does it work when you lookup inside JBoss?
What does the binding code look like?
It is same as the sample code in document.
private void rebind() throws NamingException
InitialContext rootCtx = new InitialContext();
// Get the parent context into which we are to bind
Name fullName = rootCtx.getNameParser("").parse(jndiName);
Name parentName = fullName;
if( fullName.size() > 1 )
parentName = fullName.getPrefix(fullName.size()-1);
parentName = new CompositeName();
Context parentCtx = createContext(rootCtx, parentName);
Name atomName = fullName.getSuffix(fullName.size()-1);
String atom = atomName.get(0);
NonSerializableFactory.rebind(parentCtx, atom, new java.util.HashMap());
There's your answer,
NonSerializableFactory is for binding
stuff locally. If you send it over the wire,
the bindings are lost, they are held in a static map.
If there is any way to solve the problem? I want the registered object be accessed globally.
I assume you are talking about an MBean from the
title of this thread.
Binding an object into JNDI won't work for anything
but trivial objects, because the client will get a
You need to bind a proxy or remote object that
invokes back on the server object.
Alteratively, for an MBean use an adaptor/connector
such as the RMI adaptor. There are plenty of threads
Next week, somebody is commiting a remoting system
to JBossMX. I've not had chance to look at the details
yet, but the basic function is to allow discovery
of remote mbeans and bind them into your local
MBeanServer. The remote nature of the MBean is
transparent, I think?
In my case, I'll use session bean to wrap the registered object through JNDI lookup. The remote client can access the registered object via the session bean. It should work. Right?
Thank you very much.
That is one way of doing it :-)