db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Drake Philbrook" <...@graphtek.com>
Subject RE: Torque on Tomcat: Exception: DataSourceFactory not configured
Date Mon, 15 Mar 2004 21:10:32 GMT
Hi Brent and Ben,

I initialize Torque in a similar way with a servlet.  My problem is that
the DataSourceFactory is not being created.

Can you send me an example of a working Torque.properties file?

Thanks,

Drake 

-----Original Message-----
From: Brent Atkins [mailto:Brent.Atkins@Pro-Sys.biz] 
Sent: Monday, March 15, 2004 12:18 PM
To: Apache Torque Users List
Subject: RE: Torque on Tomcat: Exception: DataSourceFactory not
configured 

I do mine a little bit different.  I have a initialization class that
looks like this...

package foo.util;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.IOException;
import org.apache.torque.Torque;

/**
 * Torque initilization clas
 */

public class TorqueInit extends HttpServlet {
  boolean initted = false;

  public void init() {
    String prefix =  getServletContext().getRealPath("/");
    String file = getInitParameter("torque-init-file");
    if (initted == false) {
      try {
	Torque.init(prefix+file);
      } catch (Exception ex) {
	System.out.println(ex);
      }
    }
    initted = true;
  }

}

Then I have this entry in web.xml

<servlet>
  <servlet-name>torque-init</servlet-name>
  <servlet-class>foo.util.TorqueInit</servlet-class>
  <init-param>
    <param-name>torque-init-file</param-name>
    <param-value>WEB-INF/classes/Torque.properties</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>

It's not too different from Ben's code (he has a nice logger function
that I think I will add to mine; don't know how I missed it before -
thanks Ben!) but it works for me.  It's always nice to see other ways to
do it.

-----Original Message-----
From: Benjamin Yu [mailto:BenjaminY@InformativeResearch.com]
Sent: Monday, March 15, 2004 3:13 PM
To: 'Apache Torque Users List'
Subject: RE: Torque on Tomcat: Exception: DataSourceFactory not
configured


How does struts initialize Torque? Is there such a method?

For me, I use an init servlet to load the Torque properties that is
loaded on startup. I can't remember where in the docs that I read this
suggestion.

Eg:

public final void init() {
        String prefix = getServletContext().getRealPath("/");
        String file = getInitParameter("torque-init-file");
        if (file != null) {
            try {
                Torque.init(prefix + file);
            } catch (TorqueException e) {
                Logger.getInstance(TorqueInitServlet.class).fatal(
                    "Cannot Init Torque",
                    e);
            }
        }
    }

I know if I don't have that piece of code running at startup, the config
file won't get pulled in and I get the same error message you've got.

-Ben



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