You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Agent96 <Ma...@metadatatechnology.com> on 2009/03/19 16:07:06 UTC

URI resolving to tomcat/bin

Hi,

I have a URI that points to a relative location: URI myUri = new
URI("resources/myFile.xml");

When I deply my application to Tomcat the location is relative to
tomcat/bin. so it would be tomcat/bin/resource/myFile.xml.

I was hoping for [TOMCAT_HOME]/Webapps/myWebApp/classes/resources/myFile.xml
or something like that.........

Is this a Tomcat fix or a Java fix......
-- 
View this message in context: http://www.nabble.com/URI-resolving-to-tomcat-bin-tp22601353p22601353.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: URI resolving to tomcat/bin

Posted by Gregor Schneider <rc...@googlemail.com>.
On Thu, Mar 19, 2009 at 5:23 PM, Agent96
<Ma...@metadatatechnology.com> wrote:
>
> Thanks...I just came to the same conclusion too.....
>
> URI uri = MyClass.class.getResource("/resources/xsd/Message.xsd").toURI()
> which resolves to myWebApp/WEB-INF/classes/resources/xsd/Message.xsd
>

That's not recommended.

Instead of using Class.getRessourceAsStream() you should be using
ServletContext.getRessourceAsStream()

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

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


RE: URI resolving to tomcat/bin

Posted by Agent96 <Ma...@metadatatechnology.com>.
Thanks...I just came to the same conclusion too.....

URI uri = MyClass.class.getResource("/resources/xsd/Message.xsd").toURI()
which resolves to myWebApp/WEB-INF/classes/resources/xsd/Message.xsd

Matt



Caldarale, Charles R wrote:
> 
>> From: Agent96 [mailto:Matt.Nelson@metadatatechnology.com] 
>> Subject: URI resolving to tomcat/bin
> 
> 
>> [TOMCAT_HOME]/Webapps/myWebApp/classes/resources/myFile.xml
> 
> Classes are normally stored in myWebApp/WEB-INF/classes, but the above is
> acceptable, just unusual (assuming you fix the spelling of "webapps").
>  
>> Is this a Tomcat fix or a Java fix......
> 
> Neither; fix your webapp.  You should be using:
> 
>    ServletContext.getResourceAsStream("/classes/resources/myFile.xml");
> 
> There's no guarantee the container will provide any access to the file
> system, other than the temporary work area defined by the servlet spec.
> 
>  - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/URI-resolving-to-tomcat-bin-tp22601353p22603089.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: URI resolving to tomcat/bin

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

Chuck,

On 3/19/2009 12:15 PM, Caldarale, Charles R wrote:
>> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
>> Subject: Re: URI resolving to tomcat/bin
>>
>>> ServletContext.getResourceAsStream("/classes/resources/myFile.xml");
>>
>> I think Chuck meant:
>>
>> ServletContext.getResourceAsStream("/WEB-INF/classes/resources
>> /myFile.xml");
> 
> No, Chuck didn't, since the OP's file is not under WEB-INF; read the original post.

Oh, right. That /is/ weird.

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

iEYEARECAAYFAknCc7UACgkQ9CaO5/Lv0PAbcACguGhmNx8uFWly82P1eZ3SlUuJ
0/sAoIzFUQ8ZQVudIlIfzHU8erzIvL1L
=ZAZs
-----END PGP SIGNATURE-----

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


RE: URI resolving to tomcat/bin

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: URI resolving to tomcat/bin
> 
> > ServletContext.getResourceAsStream("/classes/resources/myFile.xml");
> 
> I think Chuck meant:
> 
> ServletContext.getResourceAsStream("/WEB-INF/classes/resources
> /myFile.xml");

No, Chuck didn't, since the OP's file is not under WEB-INF; read the original post.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: URI resolving to tomcat/bin

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

Agent96,

On 3/19/2009 11:17 AM, Caldarale, Charles R wrote:
> ServletContext.getResourceAsStream("/classes/resources/myFile.xml");

I think Chuck meant:

ServletContext.getResourceAsStream("/WEB-INF/classes/resources/myFile.xml");

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

iEYEARECAAYFAknCaecACgkQ9CaO5/Lv0PAkUACgqqMT8uLr1fcbpgYCwEAd0h7q
IpIAoJMJ66j1v6o9J9AEbNq6fo4RkDkb
=nCAs
-----END PGP SIGNATURE-----

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


RE: URI resolving to tomcat/bin

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Agent96 [mailto:Matt.Nelson@metadatatechnology.com] 
> Subject: URI resolving to tomcat/bin


> [TOMCAT_HOME]/Webapps/myWebApp/classes/resources/myFile.xml

Classes are normally stored in myWebApp/WEB-INF/classes, but the above is acceptable, just unusual (assuming you fix the spelling of "webapps").
 
> Is this a Tomcat fix or a Java fix......

Neither; fix your webapp.  You should be using:

   ServletContext.getResourceAsStream("/classes/resources/myFile.xml");

There's no guarantee the container will provide any access to the file system, other than the temporary work area defined by the servlet spec.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org