You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vincent <v-...@ifrance.com> on 2005/06/09 23:53:57 UTC
Problem for loading files under WEB-INF/classes
I want to load some files that I've placed in the WEB-INF/classes
directory of my project (particularly the file log4j.properties).
The problem is that I always have the same errors logged in stdout
tomcat's log file : java.io.FileNotFoundException...
The files are well-placed, and curiously my webapp can read a ressource
bundle file that I provide for i18n, which is in this same directory.
I believed that Tomcat automatically place files under WEB-INF/classes
into the path of the webapp. I'm wrong ? What's the problem exactly ?
Thank you for your help.
Note: Running Tomcat 5.5.9 under Windows XP or Windows 2000, JVM 1.5
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Problem for loading files under WEB-INF/classes
Posted by Tim Diggins <su...@red56.co.uk>.
If they are under WEB-INF/classes then should be in your classpath,
unless something is really wrong, so you can access them using
getClass().getResourceAsStream("/full/path/from web-inf_class") or
getClass().getResourceAsStream("relativepath_from_class").
or use getClass().getResource().
if that isn't working, then I'm stumped.
Tim
Vincent wrote:
> I want to load some files that I've placed in the WEB-INF/classes
> directory of my project (particularly the file log4j.properties).
>
> The problem is that I always have the same errors logged in stdout
> tomcat's log file : java.io.FileNotFoundException...
>
> The files are well-placed, and curiously my webapp can read a ressource
> bundle file that I provide for i18n, which is in this same directory.
>
> I believed that Tomcat automatically place files under WEB-INF/classes
> into the path of the webapp. I'm wrong ? What's the problem exactly ?
>
> Thank you for your help.
>
> Note: Running Tomcat 5.5.9 under Windows XP or Windows 2000, JVM 1.5
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Problem for loading files under WEB-INF/classes
Posted by Dirk Weigenand <Di...@gmx.de>.
Hi,
>
> I want to load some files that I've placed in the WEB-INF/classes
> directory of my project (particularly the file log4j.properties).
>
> The problem is that I always have the same errors logged in stdout
> tomcat's log file : java.io.FileNotFoundException...
>
you can load your properties via
InputStream is = getClass().getResourceAsStream( "/log4j.properties" );
> The files are well-placed, and curiously my webapp can read a ressource
> bundle file that I provide for i18n, which is in this same directory.
>
> I believed that Tomcat automatically place files under WEB-INF/classes
> into the path of the webapp. I'm wrong ? What's the problem exactly ?
>
> Thank you for your help.
>
> Note: Running Tomcat 5.5.9 under Windows XP or Windows 2000, JVM 1.5
>
Works for me with Tomcat 5.5.7/Windows XP and Tomcat 5.5.9/Debian Sarge.
regards,
Dirk
--
Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Problem for loading files under WEB-INF/classes
Posted by Vincent <v-...@ifrance.com>.
Hi,
Thanks all three for answering.
In fact, the error seems to appear because the loading of the file is
done in the static{} initializer of a class. By loading the properties
elsewhere it works (at least there's no FileNotFoundException yet,
having a well configured log4j.properties is another business ^^).
Vincent.
Vincent wrote:
> I want to load some files that I've placed in the WEB-INF/classes
> directory of my project (particularly the file log4j.properties).
>
> The problem is that I always have the same errors logged in stdout
> tomcat's log file : java.io.FileNotFoundException...
>
> The files are well-placed, and curiously my webapp can read a ressource
> bundle file that I provide for i18n, which is in this same directory.
>
> I believed that Tomcat automatically place files under WEB-INF/classes
> into the path of the webapp. I'm wrong ? What's the problem exactly ?
>
> Thank you for your help.
>
> Note: Running Tomcat 5.5.9 under Windows XP or Windows 2000, JVM 1.5
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Problem for loading files under WEB-INF/classes
Posted by GB Developer <gb...@globallyboundless.com>.
You might consider the following:
1) if you wrote log4j.properties on one platform and uploaded it to another,
perhaps the format got mangled. Check to be sure that log4j.properties is
actually "log4j.properties", without some special, non-printable and hidden
character on the end of the filename. I once had a problem where for some
reason, my SFTP client was adding a ~ to the end of all my files. The SFTP
client didn't show them, but if you logged into a shell and "ls -l", you'd
see the ~.
2) check *inside* the file for things like line return nonsense (CRLF vs. CR
vs. LF) and gibberish characters.
3) check that log4j.properties has the correct file permissions (it's owned
by the correct user/group). To be sure, chmod +777 should work.
> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Vincent
> Sent: Thursday, June 09, 2005 4:54 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Problem for loading files under WEB-INF/classes
>
>
> I want to load some files that I've placed in the WEB-INF/classes
> directory of my project (particularly the file log4j.properties).
>
> The problem is that I always have the same errors logged in stdout
> tomcat's log file : java.io.FileNotFoundException...
>
> The files are well-placed, and curiously my webapp can read a
> ressource
> bundle file that I provide for i18n, which is in this same directory.
>
> I believed that Tomcat automatically place files under
> WEB-INF/classes
> into the path of the webapp. I'm wrong ? What's the problem exactly ?
>
> Thank you for your help.
>
> Note: Running Tomcat 5.5.9 under Windows XP or Windows 2000, JVM 1.5
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org