Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

global JNDI resources tomcat5

Status
Not open for further replies.

sedj

Programmer
Aug 6, 2002
5,610
Hi,

Does anyone know how to bind an object to a JNDI context that can be accessed by multiple webapps runing within the same container ?


So for example, in webapp "aaa" I would like to bind an object that can be looked up by webapp "bbb".

Currently, tomcat5 seems to not allow this ...

Cheers

 
may be this is what you mean. I have db JNDI resource declared at the server.xml level. Then I use InitialContext object to retrieve it.

<ResourceParams name="jdbc/MyDB">

This way, multiple web apps can access server.xml for the values.

~za~
You can't bring back a dead thread!
 
Hi maxpower1, yes this is what I ended up doing, but it was not really what I really needed - which was to bind to a global JNDI context from a webapp context without having to worry about configuring server.xml. I think its very poor on Tomcat's behalf that this is not possible. Still ,there you go !
 
J2EE offers a more suitable implementation where you can define all your <env-entry> in ejb-jar.xml at the <enterprise-bean> level. I'm not sure whether you're using J2EE or not.

Think about it though, only starting JDK 1.4, JNDI is incorporated into java. SDK 1.3 doesn't have this feature. Hopefullly JDK 1.5 will be a lot better.

Until then, server.xml is not a bad approach. Else, you can try and use Class Loader and load up your own xml file. I never try this but it's only a suggestion.



~za~
You can't bring back a dead thread!
 
maxpower1 :
Thanks for the reply.

We are not using EJB, so that is not an option, but even if we were this would not have solved the problem. As for using a class loader - this would not help either.

We've got around the problem, so its no worries, but the problem is inherent to Tomcat - that you cannot bind objects to JNDI globally without some kind of entry in server.xml. That was the problem. This is because the way that tomcat implements InitialContext - the writers took a choice to bind JNDI variiables on a context by context basis for non-tomcat code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top