-
Here is the query
env.put(Context.PROVIDER_URL,"t3://localhost:7001");
this is how u get the InitialContext for doing the jndi lookup.
here we have hard coded the url as "t3://localhost:7001"
is there any way to know abt the server name dynamically
Thanks,
-
hello Karthikeyan,
In the case of a servlet that is invoking the bean, the following code shows how you can get the url from the incoming Context structure.
String initCtxFactory = getInitparamter(Context.Initial_context_Factory);
String ProviderURL = getInitparamter(Context.provider_url);
// ADD JNDI init paramter to a properties object.
properties env = new properties();
evn.put(Context.INITIAL_CONTEXT_FACTORY, initCtxFactory);
evn.put(Context.provider_url,ProviderURL);
The other way is for the Deployer to specify this when deploying the beans. In that situation you would just use
the default InitialContext in your code thus:
InitialContext inictx = new InitialContext();
The above picks up the initial context information from whatever the deployer specified during bean deployment.
Thanks
-U