You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Anton Tagunov <at...@mail.cnt.ru> on 2003/09/08 07:57:59 UTC

Re[2]: Deployment problems in tomcat 4.1.27 : jdbc and properties files

Hello Shailesh!

SM> properties files(configuration files) for my web-app are not getting
SM> picked up. I have tried following ways one by one:
SM> 1. kept them in \WEB-INF\classes folder
the right move
SM> 2. kept them in \WEB-INF\lib
won't work, it's for jars only
SM> 3. made the jar out of them and kept that jar in lib directory too
would work too, but looks like an overkill. BUT, you may pack them
into the same jar as your application classes are in and keep THAT
in /WEB-INF/lib, this would be quite reasonable
SM>  but whenever my bootstrap code runs, it doesn't find these properties
SM> files.

SM> Code is :
SM>  InputStream myStream =
SM> ClassLoader.getSystemResourceAsStream("framework.properties");

SM> or
SM>  InputStream myStream =
SM> ClassLoader.getSystemResourceAsStream("/WEB-INF/properties/framework.propert
SM> ies");
Should have been, assumint you have
    /WEB-INF/classes/framework.properties
or
    /WEB-INF/lib/some.jar!/framework.properties

    Thread.getContextClassLoader().getResourceAsStream("framework.properties");

An noteworthy alternative is, assuming you have
    /WEB-INF/properties/framework.properties

inside a servlet

    this.getServletContext().getResourceAsStream("/WEB-INF/properties/framework.properties");

inside a jsp
    <%
        ... =
            application.getResourceAsStream("/WEB-INF/properties/framework.properties");
    %>

Anton


Re: Re[2] :Deployment problems in tomcat 4.1.27 : jdbc and properties files

Posted by Shailesh Modi <sh...@cisco.com>.
  Atlast it worked by changing code to use
Thread.getContextClassLoader().getResourceAsStream("framework.properties");
to load my files.

 Anton, Thanks a lot :)

regards
Shailesh

-----Original Message-----
From: Anton Tagunov [mailto:atagunov@mail.cnt.ru]
Sent: Monday, September 08, 2003 11:28 AM
To: Tomcat Users List; shmodi@cisco.com
Subject: Re[2]: Deployment problems in tomcat 4.1.27 : jdbc and
properties files


Hello Shailesh!

SM> properties files(configuration files) for my web-app are not getting
SM> picked up. I have tried following ways one by one:
SM> 1. kept them in \WEB-INF\classes folder
the right move
SM> 2. kept them in \WEB-INF\lib
won't work, it's for jars only
SM> 3. made the jar out of them and kept that jar in lib directory too
would work too, but looks like an overkill. BUT, you may pack them
into the same jar as your application classes are in and keep THAT
in /WEB-INF/lib, this would be quite reasonable
SM>  but whenever my bootstrap code runs, it doesn't find these properties
SM> files.

SM> Code is :
SM>  InputStream myStream =
SM> ClassLoader.getSystemResourceAsStream("framework.properties");

SM> or
SM>  InputStream myStream =
SM>
ClassLoader.getSystemResourceAsStream("/WEB-INF/properties/framework.propert
SM> ies");
Should have been, assumint you have
    /WEB-INF/classes/framework.properties
or
    /WEB-INF/lib/some.jar!/framework.properties


Thread.getContextClassLoader().getResourceAsStream("framework.properties");

An noteworthy alternative is, assuming you have
    /WEB-INF/properties/framework.properties

inside a servlet


this.getServletContext().getResourceAsStream("/WEB-INF/properties/framework.
properties");

inside a jsp
    <%
        ... =

application.getResourceAsStream("/WEB-INF/properties/framework.properties");
    %>

Anton