db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Fortytwo <...@ign.com>
Subject Re: Torque.init() can't find project.properties from servlet
Date Wed, 16 Apr 2003 22:42:43 GMT
I personally always load things using the
   CLASSNAME.class.getResourceAsStream()
method, but torque doesn't seem to allow me to specify a properties file 
using a resource location. I consider it unacceptable to hard code the path 
because I have stuff that runs from a jar file, so hard coding the path 
won't work because it won't find the file in the jar. So I just hard code 
the values directly (if I wanted to use a properties file I'd just load it 
myself and set the values in this way using the values from the properties 
file):

         // All this needs to be done because the other way of 
initialization which uses a properties
         // files will require a specific path name which means it won't 
work inside a jar.
         BaseConfiguration torqueConfig = new BaseConfiguration();

         torqueConfig.addProperty("log4j.rootCategory","DEBUG,default");
         torqueConfig.addProperty("log4j.appender.default","org.apache.log4j.FileAppender");
         torqueConfig.addProperty("log4j.appender.default.file","/jrun/logs/default/torque.log");
         torqueConfig.addProperty("log4j.appender.default.layout","org.apache.log4j.SimpleLayout");

         torqueConfig.addProperty("torque.database.default","FAKE");
         torqueConfig.addProperty("torque.database.rego.driver","oracle.jdbc.driver.OracleDriver");
         torqueConfig.addProperty("torque.database.rego.url","FAKE");
         torqueConfig.addProperty("torque.database.rego.username","FAKE");
         torqueConfig.addProperty("torque.database.rego.password","FAKE");

         org.apache.torque.Torque.init(torqueConfig);


At 02:55 PM 4/16/2003, Jon King wrote:
>Yes, it seems like the properties file should be found if it's anywhere in
>your classpath, but that hasn't been the case for me.  I've had to either
>drop the properties file into directory that the app is running in (system
>property user.dir) or provide an absolute path.
>
>Gabriel Bauman wrote:
>
> > Hello again,
> >
> > I am using Torque in a servlet environment. I can't seem to get Torque
> > to see my project.properties file, which contains the db settings etc,
> > even though it's in my WEB-INF/classes folder and is on the classpath.
> >
> > java.io.FileNotFoundException: project.properties (The system cannot
> > find the file specified)
> > ...
> >   at org.apache.torque.Torque.init(Torque.java:386)
> >
> > I'm kind of at a loss, can anyone offer some insight? I am using a
> > recent CVS snapshot of Torque.
> >
> > Thanks,
> >
> > Gabe
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message