-
1. JNDI Standalone client
wolfgangknauf Apr 4, 2011 8:51 AM (in response to ajitsaha67)Hi,
for a standalone client, you have to provide a configuration for the InitialContext:
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext initialContext = new InitialContext(props);
Do you want to perform a lookup in global JNDI or do you lookup something in your "Environment naming context"?
Best regards
Wolfgang
-
2. JNDI Standalone client
ajitsaha67 Apr 5, 2011 1:38 AM (in response to wolfgangknauf)In JBoss Community documentation, I have tested
3.4.3.1. A Standard MBean Example program it is working absolutely fine. The access code of HashMap is perfectly working. But when I am trying to access from outside JBoss, it returns null obviously I have set the environment property in following way
Properties prop=new Properties();
prop.setProperty(Context................. the way you have mensioned on previous reply.
But still it gives null value. It is not returing HashMap value.
-
3. JNDI Standalone client
jaikiran Apr 5, 2011 2:40 AM (in response to ajitsaha67)I guess the HashMap content isn't serializable.
-
4. JNDI Standalone client
ajitsaha67 Apr 5, 2011 2:54 AM (in response to jaikiran)This HashMap object I am getting in jsp program
But I am not getting in Standalone client. HashMap is Serializable object.
Shall I give you complete code, so that you can help me.
-
5. JNDI Standalone client
wolfgangknauf Apr 5, 2011 7:13 AM (in response to ajitsaha67)Hi,
I took a look at the sample at http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/Writing_JBoss_MBean_Services-A_Standard_MBean_Example.html
It uses the "NonSerializableFactory": http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/naming/NonSerializableFactory.java.html
The JavaDoc of this class states:
A utility class that allows one to bind a non-serializable object into a local JNDI context. The binding will only be valid for the lifetime of the VM in which the JNDI InitialContext lives
A utility class that allows one to bind a non-serializable object into a local JNDI context. The binding will only be valid for the lifetime of the VM in which the JNDI InitialContext lives"A utility class that allows one to bind a non-serializable object into a local JNDI context. The binding will only be valid for the lifetime of the VM in which the JNDI InitialContext lives"
To my understanding, this means that you can lookup the bound data only if your process is in the same VM. But a standalone client will not be able to see it.
There is a class "Util", which has a bunch of methods to work with JNDI bindings ( http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/naming/Util.java.html ) - maybe they allow binding to non-local VM, but I don't know this much about JNDI internal to provide further help.
Best regards
Wolfgang
-
6. JNDI Standalone client
jaikiran Apr 5, 2011 7:30 AM (in response to wolfgangknauf)Wolfgang Knauf wrote:
I took a look at the sample at http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/Writing_JBoss_MBean_Services-A_Standard_MBean_Example.html
It uses the "NonSerializableFactory": http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/naming/NonSerializableFactory.java.html
The JavaDoc of this class states:
A utility class that allows one to bind a non-serializable object into a #local JNDI context. The binding will only be valid for the lifetime of the #VM in which the JNDI InitialContext lives
A utility class that allows one to bind a non-serializable object into a #local JNDI context. The binding will only be valid for the lifetime of the #VM in which the JNDI InitialContext lives"A utility class that allows one to bind a non-serializable object into a local JNDI context. The binding will only be valid for the lifetime of the VM in which the JNDI InitialContext lives"
To my understanding, this means that you can lookup the bound data only if your process is in the same VM. But a standalone client will not be able to see it.
That's correct!