tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <jacob.r.kj...@syntegra.com>
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 
DirectoryAction.authenticateUser(Ljava/lang/String;Ljava/lang/String;)Z 
from class Security
         at Security.doPost(Security.java:39)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at 
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387)
         at org.apache.tomcat.core.Handler.service(Handler.java:263)
         at 
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371)
         at 
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:769)
         at 
org.apache.tomcat.core.ContextManager.service(ContextManager.java:715)
         at 
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
         at 
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:403)
         at 
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
         at java.lang.Thread.run(Thread.java:484)


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


Jake

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
>classpath.
>
>-Sami
>--
>Sami Lempinen <sami.lempinen@nokia.com>
>OSS Monitor / NMS Infoware Technologies
>Blame Canada.


Mime
View raw message