tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <>
Subject Re: loading a properties file - where does it expect the file to be?
Date Wed, 27 Sep 2000 13:04:23 GMT
The problem is, this isn't a servlet.  It is just a Class that I import 
into the servlet and instantiate to communicate with an ldap directory 
server.  I just had it in the same directory as the servlet for convenience 
and this works on my 3.1 install and it always works when I run it as an 
application from the command line.

All problems henceforth will be assumed to be with 3.2b5

I also tried putting it in a directory somewhere in the system classpath, 
but I get the following error report from the servlet:

2000-09-26 11:31:17 - Ctx( /mycontext ): Exception in: R( /mycontext + 
/login + null) - java.lang.IllegalAccessError: try to access method 
from class Security
         at Security.doPost(
         at javax.servlet.http.HttpServlet.service(
         at javax.servlet.http.HttpServlet.service(
         at org.apache.tomcat.core.Handler.service(

I don't understand why this would happen.  It should be able to use this 
class just like any other.  I tired putting it in TOMCAT_HOME\classes and 
tried some other directory in my casspath.  I get the same error.

When I have the class + properties file in the same directory as my 
servlet, I don't get the error above, but I do get a FileNotFoundException 
which I catch and handle, but I just cannot load that file to grab the 
properties from it.

I would think that I was doing something wrong, but again, this works on my 
Tomcat 3.1 install just fine????


At 11:44 AM 9/27/2000 +0300, you wrote:
>On Tue, Sep 26, 2000 at 11:22:48PM -0500, EXT Jacob Kjome wrote:
> > I have a servlet that uses another class that isn't a servlet which 
> loads a
> > file with properties in it.
> >
> > When I run the class as an application, it works fine.
> >
> > However, when calling it from a servlet, it can't find the file???
>How are you specifying the path to the properties file? The concept of
>working directory is different from the servlet context path.
>Solution: either specify the path relative to the servlet context path
>as in
>    // Obtain the servlet context.
>    con = getServletContext();
>    String path = con.getRealPath("/")
>                  + System.getProperty("file.separator")
>                  + con.getInitParameter("propfile")
>or use a ResourceBundle which can be located anywhere in your
>Sami Lempinen <>
>OSS Monitor / NMS Infoware Technologies
>Blame Canada.

View raw message