Have you tried a leading slash?
file1 = getServletContext().getResource( "/WEB-INF/log4j.xml" );
What we do, is get the "real" path with:
String realPath = this.getServletContext().getRealPath( "/WEB-INF/dir" );
new File( realPath, fileName );
We do this because getResource() is so dependent on ClassLoaders.
tim.
> Hi,
>
> I wanted to port a (running) application from tomcat to orion. It seems
> my coding is not proper/portable.
>
> In my war-archive included (in WEB-INF subdirectory) are several
> text config files (yes I know JNDI is a better way -but its lowest common
> functionality) - and these files I want to access in my servlet code.
>
> Following servlet code does not find these files running in orion while
> working fine with tomcat 3.2.
>
> For a beginner: whats the correct way to load such files ?
>
> ----------------------------------------------------------------------------
> --------------------------------
>
> package de.adig.vbh.wc.controller;
> ...
> public class UIMain extends HttpServlet {
> ...
> file1 = getServletContext().getResource("WEB-INF/log4j.xml");
>
> file2 =
> getServletContext().getResource("WEB-INF/wc-config.xml");
>
> ----------------------------------------------------------------------------
> --------------------------------
>
> ==> both files are null in orion, but found in tomcat.
>
> files are in dir WEB-INF/ that is in a war-archive that is in an
> ear-archive.
> they got successfully unpacked by orion and can be seen in orionconsole
>
> Manfred Regele
> ADIG Investment GmbH
> 22 Methoden&Tools
> Richard-Reitzner-Allee 2
> 85540 Haar
> Tel: 089/46268-308
> mailto:[EMAIL PROTECTED]
> http://www.adig.de
>
>