Finding the Torque.properties file also depends on your application server. In the 
(Bcase of BEA WebLogic I had the same problem with unexploded WAR files. Therefore I 
(Bused the class loading incarnation of commons configuration - I can send you my source 
(Bcode to your private mail account
(B
(BIf you have more thing to initialize and manage in as servlet (and have a little bit 
(Bof spare time) you should look at a service framework such as Turbine or Avalaon.
(B
(BCheers,
(B
(BSiegfried Goeschl
(B
(B-----Original Message-----
(BFrom: Hassan Abolhassani [mailto:[EMAIL PROTECTED]
(BSent: Tuesday, January 27, 2004 7:33 AM
(BTo: Apache Torque Users List
(BSubject: Re: Web Applications
(B
(B
(B>Hey everybody, st00pid newbie here... I've gone through the torque 
(B>tutorial successfully and experimented a bit beyond it but now I'm 
(B>trying to use torque in a web application for the first time and have 
(B>run into some trouble.  I'm confused about the Torque.properties file 
(B>and the init() method.  I've placed the Torque.properties file in the 
(B>root of my .war, in WEB-INF/, WEB-INF/classes, WEB-INF/lib, just about 
(B>everywhere, but when I call init("Torque.properties") it can't find it. 
(B>  Where is it supposed to live and how do I reference it?  
(B
(BMy solution is to have an initializer servlet. It passes a phycial path
(Bof the properties file to the init(). Attached is a copy of that servlet
(Bthat might be usefull for you. 
(B
(BYou need to make it called when the servlet engine is started. To do
(Bthat the following snippet in web.xml of your application will work:
(B
(B  <servlet>
(B    <servlet-name>initializer</servlet-name>
(B    <servlet-class>com.utility.Initializer</servlet-class>
(B
(B    <init-param>
(B      <param-name>log4j-property-file</param-name>
(B      <param-value>WEB-INF/classes/log4j.properties</param-value>
(B    </init-param>
(B
(B    <init-param>
(B      <param-name>torque-property-file</param-name>
(B      <param-value>WEB-INF/classes/Torque.properties</param-value>
(B    </init-param>
(B
(B    <load-on-startup>1</load-on-startup>
(B  </servlet>
(B
(BPlease note that the servlet also initializes log4j, which you may want
(Bto ignore it.
(B
(B>Also, do I 
(B>call init() in each class that uses Torque or do I need to somehow only 
(B>call it once when the web app is deployed?  Sorry if this is a dumb 
(B>question, but I can't find anything in the docs to help me.  Thanks 
(B>much.
(B
(BYou only need to call init() one time.
(B
(B--Travis Hanna
(B
(B___
(B
(BRazorfish Japan, Inc.
(B
$B%"%\%k%O%C%5%K!!%O%C%5%s(J   Hassan Abolhassani  [Technology network]
$B3t<02q

Reply via email to