Tomcat context environment variables question

J

Jimbo

Hi People,
I have some classes that form the basis of my application that is
deployed under Tomcat. Those classes use environment variables set in
the application context and accessed via JNDI (InitialContext,
DataSource etc). However, I now want to use my classes outside tomcat.
Is there a simple way of supplying the context information from the
command line so that the JNDI code can access it?

Cheers
Jimbo.
 
R

Raymond DeCampo

Jimbo said:
Hi People,
I have some classes that form the basis of my application that is
deployed under Tomcat. Those classes use environment variables set in
the application context and accessed via JNDI (InitialContext,
DataSource etc). However, I now want to use my classes outside tomcat.
Is there a simple way of supplying the context information from the
command line so that the JNDI code can access it?

Jimbo,

That depends. When you say "outside tomcat", do you mean external to
tomcat with tomcat serving as the JNDI server? In that case, look at
the documentation for InitialContext, etc. Look for how to define the
jndi.properties.

If you mean as a standalone application that does not speak to tomcat,
then you have a lot more work to do. JNDI requires a provider, i.e. an
implementation. Last I checked, the ones that came with the JRE were
not useful for your purposes. So you have two options:

1) Decouple the JNDI client code behind an interface. When running in
tomcat, use JNDI to implement the interface. When running outside
tomcat, use another implementation.

2) Create an implementation of JNDI that can serve you outside of
tomcat. For example, it is not really all that difficult to create a
Map-based JNDI implementation.

HTH,
Ray
 
J

Jimbo

Raymond said:
Jimbo,

That depends. When you say "outside tomcat", do you mean external to
tomcat with tomcat serving as the JNDI server? In that case, look at
the documentation for InitialContext, etc. Look for how to define the
jndi.properties.

If you mean as a standalone application that does not speak to tomcat,
then you have a lot more work to do. JNDI requires a provider, i.e. an
implementation. Last I checked, the ones that came with the JRE were
not useful for your purposes. So you have two options:

1) Decouple the JNDI client code behind an interface. When running in
tomcat, use JNDI to implement the interface. When running outside
tomcat, use another implementation.

2) Create an implementation of JNDI that can serve you outside of
tomcat. For example, it is not really all that difficult to create a
Map-based JNDI implementation.

HTH,
Ray

Thanks Ray,
Tomcat is around and running its just that my code is being started
from the command line rather than via a server. I'll take a look at the
jndi.properties stuff then.

Ta
Jimbo.
 
J

Jimbo

Jimbo said:
Thanks Ray,
Tomcat is around and running its just that my code is being started
from the command line rather than via a server. I'll take a look at the
jndi.properties stuff then.

Ta
Jimbo.

Using google I've found lots of useful information about using
org.apache.naming.config.XmlConfigurator to load JNDI information.
However I can't find this class or package anywhere. Searching
apache.org I find several dead links.

Does anyone have any ideas?

Cheers
Jimbo
 
J

Jimbo

Using google I've found lots of useful information about using
org.apache.naming.config.XmlConfigurator to load JNDI information.
However I can't find this class or package anywhere. Searching
apache.org I find several dead links.

Does anyone have any ideas?

Cheers
Jimbo

No problem, all sorted. Found them after much digging on the apache
website.

Jimbo.
 
Joined
Oct 11, 2006
Messages
1
Reaction score
0
XMLConfigurator

Hi Jimbo,
I am trying to implement that 1st approach and looking into couple of ENC providers including tomcat. I tried apache naming website but couldnt find anything but 404 links. Could you please provide the url to look into this XMLConfigurator class and other packages.
thanks
karthik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top