You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Robert Soeding <ro...@gmx.net> on 2007/05/23 14:37:22 UTC

WebApps not isolated

Hi, since this is my first posting in this mailing list, I would like to 
thank you very much for providing and maintaining Tomcat.

I'm using Tomcat 5.5.20 and .23, Sun Java 1.5.x, on Ubuntu 7.04.

I've deployed two identical WebApps, webapp1 and webapp2, by letting 
Tomcat unpack two WAR files. Next I changed 
$CATALINA_HOME/webapps/webappX/WEB-INF/classes/myProps.properties in 
both webapps to point to different databases. Next, I restarted Tomcat.

The code to access properties is simply,
    ResourceBundle.getBundle("myProps").getString(key);

The problem is, both webapp1 and webapp2 access the same 
myProps.properties (webapp2 access webapp1's myProps.properties). When I 
undeploy webapp1, webapp2 will use its own properties file again.

As an additional test, I downloaded a fresh copy of Tomcat, deployed 
both webapps, edited myProps.properties, and ran this fresh instance. In 
this instance, webapp1 would use the properties file of webapp2 (while 
in the other instance of Tomcat, webapp2 would access webapp1's 
properties file).

Anyways, both webapps are not isolated properly.

On another server I was not able to reproduce this behavior, using the 
same WAR files.

I've also looked for JARs that might contain the properties file in the 
$CLASSPATH, $CATALINA_HOME/common/* and 
$CATALINA_HOME/webapps/webapp1/WEB-INF/lib, but such a JAR does not 
exist. Moreover, different properties files are used, probably, 
depending on which webapp is loaded first.

Any ideas?

Thanks
Robert

---------------------------------------------------------------------
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: [partly solved] WebApps not isolated

Posted by Robert Soeding <ro...@gmx.net>.
Running the same code from a JSP, the right property file will be used.
Thus, I'll proceed with the PHP-Java-Bridge.

Thanks, all, for your time and knowledge.


Robert Soeding wrote:
> Thanks.
>
> This is a PHP web, PHP files being interpreted by a Servlet provided 
> by PHP-Java-Bridge.
>
> PHP files instantiate a new Java class of mine, which in turn calls a 
> static Java class of mine which returns the properties.
>
> My Java classes are within the webs only (that is under 
> $CATALINA_HOME/webapps/webappX/WEB-INF/classes).
>
>
> Reich, Matthias wrote:
>> ResourceBundle.getBundle uses the ClassLoader that was used to load the
>> class that's calling this method when it looks up the resource.
>>
>> Have you checked that the class which contains the call to
>> ResourceBundle.getBundle
>> is loaded by the expected WebappClassLoaders?
>>
>> Matthias
>>
>>
>>  
>>> -----Original Message-----
>>> From: Robert Soeding [mailto:robert.soeding@gmx.net] Sent: 
>>> Wednesday, May 23, 2007 2:37 PM
>>> To: users@tomcat.apache.org
>>> Subject: WebApps not isolated
>>>
>>> Hi, since this is my first posting in this mailing list, I would 
>>> like to thank you very much for providing and maintaining Tomcat.
>>>
>>> I'm using Tomcat 5.5.20 and .23, Sun Java 1.5.x, on Ubuntu 7.04.
>>>
>>> I've deployed two identical WebApps, webapp1 and webapp2, by letting 
>>> Tomcat unpack two WAR files. Next I changed 
>>> $CATALINA_HOME/webapps/webappX/WEB-INF/classes/myProps.properties in 
>>> both webapps to point to different databases. Next, I restarted Tomcat.
>>>
>>> The code to access properties is simply,
>>>     ResourceBundle.getBundle("myProps").getString(key);
>>>
>>> The problem is, both webapp1 and webapp2 access the same 
>>> myProps.properties (webapp2 access webapp1's myProps.properties). 
>>> When I undeploy webapp1, webapp2 will use its own properties file 
>>> again.
>>>
>>> As an additional test, I downloaded a fresh copy of Tomcat, deployed 
>>> both webapps, edited myProps.properties, and ran this fresh 
>>> instance. In this instance, webapp1 would use the properties file of 
>>> webapp2 (while in the other instance of Tomcat, webapp2 would access 
>>> webapp1's properties file).
>>>
>>> Anyways, both webapps are not isolated properly.
>>>
>>> On another server I was not able to reproduce this behavior, using 
>>> the same WAR files.
>>>
>>> I've also looked for JARs that might contain the properties file in 
>>> the $CLASSPATH, $CATALINA_HOME/common/* and 
>>> $CATALINA_HOME/webapps/webapp1/WEB-INF/lib, but such a JAR does not 
>>> exist. Moreover, different properties files are used, probably, 
>>> depending on which webapp is loaded first.
>>>
>>> Any ideas?
>>>
>>> Thanks
>>> Robert
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>>
>>>
>>>     
>>
>> ---------------------------------------------------------------------
>> 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
>>
>>   
>
>
> ---------------------------------------------------------------------
> 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
>


---------------------------------------------------------------------
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: WebApps not isolated

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Robert Soeding [mailto:robert.soeding@gmx.net] 
> Subject: Re: WebApps not isolated
> 
> PHP files instantiate a new Java class of mine, which in turn calls a 
> static Java class of mine which returns the properties.
> 
> My Java classes are within the webs only (that is under 
> $CATALINA_HOME/webapps/webappX/WEB-INF/classes).

Are you absolutely positive about that?  Might be interesting to add
some debug traces to display the name of the classloader for the static
class when the properties are being stored and retrieved, and make sure
it's really where you think it is.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
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: WebApps not isolated

Posted by Robert Soeding <ro...@gmx.net>.
Thanks.

This is a PHP web, PHP files being interpreted by a Servlet provided by 
PHP-Java-Bridge.

PHP files instantiate a new Java class of mine, which in turn calls a 
static Java class of mine which returns the properties.

My Java classes are within the webs only (that is under 
$CATALINA_HOME/webapps/webappX/WEB-INF/classes).


Reich, Matthias wrote:
> ResourceBundle.getBundle uses the ClassLoader that was used to load the
> class that's calling this method when it looks up the resource.
>
> Have you checked that the class which contains the call to
> ResourceBundle.getBundle
> is loaded by the expected WebappClassLoaders?
>
> Matthias
>
>
>   
>> -----Original Message-----
>> From: Robert Soeding [mailto:robert.soeding@gmx.net] 
>> Sent: Wednesday, May 23, 2007 2:37 PM
>> To: users@tomcat.apache.org
>> Subject: WebApps not isolated
>>
>> Hi, since this is my first posting in this mailing list, I 
>> would like to 
>> thank you very much for providing and maintaining Tomcat.
>>
>> I'm using Tomcat 5.5.20 and .23, Sun Java 1.5.x, on Ubuntu 7.04.
>>
>> I've deployed two identical WebApps, webapp1 and webapp2, by letting 
>> Tomcat unpack two WAR files. Next I changed 
>> $CATALINA_HOME/webapps/webappX/WEB-INF/classes/myProps.properties in 
>> both webapps to point to different databases. Next, I 
>> restarted Tomcat.
>>
>> The code to access properties is simply,
>>     ResourceBundle.getBundle("myProps").getString(key);
>>
>> The problem is, both webapp1 and webapp2 access the same 
>> myProps.properties (webapp2 access webapp1's 
>> myProps.properties). When I 
>> undeploy webapp1, webapp2 will use its own properties file again.
>>
>> As an additional test, I downloaded a fresh copy of Tomcat, deployed 
>> both webapps, edited myProps.properties, and ran this fresh 
>> instance. In 
>> this instance, webapp1 would use the properties file of 
>> webapp2 (while 
>> in the other instance of Tomcat, webapp2 would access webapp1's 
>> properties file).
>>
>> Anyways, both webapps are not isolated properly.
>>
>> On another server I was not able to reproduce this behavior, 
>> using the 
>> same WAR files.
>>
>> I've also looked for JARs that might contain the properties 
>> file in the 
>> $CLASSPATH, $CATALINA_HOME/common/* and 
>> $CATALINA_HOME/webapps/webapp1/WEB-INF/lib, but such a JAR does not 
>> exist. Moreover, different properties files are used, probably, 
>> depending on which webapp is loaded first.
>>
>> Any ideas?
>>
>> Thanks
>> Robert
>>
>> ---------------------------------------------------------------------
>> 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
>>
>>
>>     
>
> ---------------------------------------------------------------------
> 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
>
>   


---------------------------------------------------------------------
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: WebApps not isolated

Posted by "Reich, Matthias" <ma...@siemens.com>.
ResourceBundle.getBundle uses the ClassLoader that was used to load the
class that's calling this method when it looks up the resource.

Have you checked that the class which contains the call to
ResourceBundle.getBundle
is loaded by the expected WebappClassLoaders?

Matthias


> -----Original Message-----
> From: Robert Soeding [mailto:robert.soeding@gmx.net] 
> Sent: Wednesday, May 23, 2007 2:37 PM
> To: users@tomcat.apache.org
> Subject: WebApps not isolated
> 
> Hi, since this is my first posting in this mailing list, I 
> would like to 
> thank you very much for providing and maintaining Tomcat.
> 
> I'm using Tomcat 5.5.20 and .23, Sun Java 1.5.x, on Ubuntu 7.04.
> 
> I've deployed two identical WebApps, webapp1 and webapp2, by letting 
> Tomcat unpack two WAR files. Next I changed 
> $CATALINA_HOME/webapps/webappX/WEB-INF/classes/myProps.properties in 
> both webapps to point to different databases. Next, I 
> restarted Tomcat.
> 
> The code to access properties is simply,
>     ResourceBundle.getBundle("myProps").getString(key);
> 
> The problem is, both webapp1 and webapp2 access the same 
> myProps.properties (webapp2 access webapp1's 
> myProps.properties). When I 
> undeploy webapp1, webapp2 will use its own properties file again.
> 
> As an additional test, I downloaded a fresh copy of Tomcat, deployed 
> both webapps, edited myProps.properties, and ran this fresh 
> instance. In 
> this instance, webapp1 would use the properties file of 
> webapp2 (while 
> in the other instance of Tomcat, webapp2 would access webapp1's 
> properties file).
> 
> Anyways, both webapps are not isolated properly.
> 
> On another server I was not able to reproduce this behavior, 
> using the 
> same WAR files.
> 
> I've also looked for JARs that might contain the properties 
> file in the 
> $CLASSPATH, $CATALINA_HOME/common/* and 
> $CATALINA_HOME/webapps/webapp1/WEB-INF/lib, but such a JAR does not 
> exist. Moreover, different properties files are used, probably, 
> depending on which webapp is loaded first.
> 
> Any ideas?
> 
> Thanks
> Robert
> 
> ---------------------------------------------------------------------
> 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
> 
> 

---------------------------------------------------------------------
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: WebApps not isolated

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

Robert,

Robert Soeding wrote:
> As an additional test, I downloaded a fresh copy of Tomcat, deployed 
> both webapps, edited myProps.properties, and ran this fresh instance.
> In this instance, webapp1 would use the properties file of webapp2
> (while in the other instance of Tomcat, webapp2 would access
> webapp1's properties file).

How do you do your deployment? If you use WAR files, then the WARs might
be re-expanded when you re-deploy, overwriting your properties files.
You might want to try updating the properties file in the WAR in that case.

> Anyways, both webapps are not isolated properly.

This does not imply improper isolation... it implies improper deployment
or configuration.

> On another server I was not able to reproduce this behavior, using
> the same WAR files.

Which one?

> Moreover, different properties files are used, probably, depending on
> which webapp is loaded first.

Have you verified this, or are you just guessing?

- -chris

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

iD8DBQFGVFWp9CaO5/Lv0PARAsl5AJ9BMZ8p02TL1TOmNNmKwUwoP78cNQCcC+QO
QuSPFogu7FIoNicYPB3t+/A=
=lr/T
-----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


Re: WebApps not isolated

Posted by Martin Gainty <mg...@hotmail.com>.
Good Morning Robert

It *sounds* as if you may have one of 2 situations to deal with

a ClassLoader issue which by default goes to ClassLoader for the referenced 
class e.g. this.getClass().getClassLoader
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader)

The other scenario is that it is possible your base parameter is incorrect 
in which case you want to look at
"specifying a path name (using "/") instead of a fully qualified class name 
(using ".")"

Anyone else?
Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Robert Soeding" <ro...@gmx.net>
To: <us...@tomcat.apache.org>
Sent: Wednesday, May 23, 2007 8:37 AM
Subject: WebApps not isolated


> Hi, since this is my first posting in this mailing list, I would like to 
> thank you very much for providing and maintaining Tomcat.
>
> I'm using Tomcat 5.5.20 and .23, Sun Java 1.5.x, on Ubuntu 7.04.
>
> I've deployed two identical WebApps, webapp1 and webapp2, by letting 
> Tomcat unpack two WAR files. Next I changed 
> $CATALINA_HOME/webapps/webappX/WEB-INF/classes/myProps.properties in both 
> webapps to point to different databases. Next, I restarted Tomcat.
>
> The code to access properties is simply,
>    ResourceBundle.getBundle("myProps").getString(key);
>
> The problem is, both webapp1 and webapp2 access the same 
> myProps.properties (webapp2 access webapp1's myProps.properties). When I 
> undeploy webapp1, webapp2 will use its own properties file again.
>
> As an additional test, I downloaded a fresh copy of Tomcat, deployed both 
> webapps, edited myProps.properties, and ran this fresh instance. In this 
> instance, webapp1 would use the properties file of webapp2 (while in the 
> other instance of Tomcat, webapp2 would access webapp1's properties file).
>
> Anyways, both webapps are not isolated properly.
>
> On another server I was not able to reproduce this behavior, using the 
> same WAR files.
>
> I've also looked for JARs that might contain the properties file in the 
> $CLASSPATH, $CATALINA_HOME/common/* and 
> $CATALINA_HOME/webapps/webapp1/WEB-INF/lib, but such a JAR does not exist. 
> Moreover, different properties files are used, probably, depending on 
> which webapp is loaded first.
>
> Any ideas?
>
> Thanks
> Robert
>
> ---------------------------------------------------------------------
> 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
>
> 


---------------------------------------------------------------------
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