You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jacob Rhoden <ja...@rhoden.id.au> on 2007/10/21 10:56:06 UTC

Resource vs Resource-ref

Hi,
 
I am having trouble with something google and the docs cant seem to help.

1) After setting up a connection to a database in the context.xml file 
using the <Resource> tag, do you need the <resource-ref> in the web.xml 
file. I have tried with and without and it doesn't seem to make a 
difference.

2) I want to be able to deploy two instances of an application on the 
same installation of tomcat. (using two separate virtual hosts) with two 
separate databases. If I simply deploy the application twice, with two 
different context.xml files, sometimes this works (ie one instance uses 
the database from one context.xml and the other instance uses the 
database from the other context.xml) but sometimes it seems they both 
use the same database!!

How do I fix this? The tomcat documentation seems to imply the 
context.xml file jndi information is local to a single applications 
context. It appears this is not true if that is what the documentation 
means.

Best Regards,
Jacob

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Resource vs Resource-ref

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jacob,

Jacob Rhoden wrote:
> 1) After setting up a connection to a database in the context.xml file
> using the <Resource> tag, do you need the <resource-ref> in the web.xml
> file. I have tried with and without and it doesn't seem to make a
> difference.

I have had the same experience in Tomcat 4.1 and 5.5.

> 2) I want to be able to deploy two instances of an application on the
> same installation of tomcat. (using two separate virtual hosts) with two
> separate databases. If I simply deploy the application twice, with two
> different context.xml files, sometimes this works (ie one instance uses
> the database from one context.xml and the other instance uses the
> database from the other context.xml) but sometimes it seems they both
> use the same database!!

That doesn't make any sense. Are you sure you have your configuration
correct? Please post your context.xml (and indicate where the two
differ) and also your VirtualHost sections from server.xml.

> How do I fix this? The tomcat documentation seems to imply the
> context.xml file jndi information is local to a single applications
> context. It appears this is not true if that is what the documentation
> means.

Your understanding of the documentation is correct; while it's possible
that Tomcat has a bug, it is much more likely that you have an incorrect
configuration which is causing this bizarre behavior. Either that, or
you sometimes deploy the wrong context.xml file in your WAR file.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHG2839CaO5/Lv0PARAmzNAKCWJ5XEe2Wos8yCzC9OeEvOP7/aFgCfWM6C
teuYS62ILMgwnf+wPYTiCHw=
=Eidt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org