Peter Hutchinson wrote:
> Hi,
> I have implemented DB connection pooling based on the Hans Bergsten chapter
>in
> Wrox's Professional Java Server Programming using the iPlanet web server on an NT
> machine. It works fine but only when I use the following to open the db.properties
> file :
>
> is = new FileInputStream("..\\db.properties");
>
> with the file placed in the root C: directory. Any attempt to use the code specified
> in the book :
>
> InputStream is = getClass().getResourceAsStream("/db.properties");
>
> fails as the file is not found. I have tried putting the file in every possible
> CLASSPATH location I could think of, used a relative path and no path at all but to
>no
> avail.
>
> Does anybody have any suggestions?
The getResourceAsStream() method is implemented by the class loader, and
if iPlanet is using their own class loader for servlets (likely) and have
not implemented this method the same way as the default class loader, you
may have a problem. One way around this problem is to make sure the pool
classes are not loaded by their special class loader, but by the primordial
class loader. Typically that's what happens if you place the classes in the
class path used by the servlet container itself as opposed to the directories
used for storing servlet classes (see the iPlanet docs for details).
As an alternative, you can use a servlet to initialize the connection pool, and
specify an init parameter for this servlet that contains the absolute path for
the properties file.
Regards,
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html