I'm using Struts and Torque and they work wonderfully together, so it
should be possible to get the two to behave.
We subclassed ActionServlet to make a TorqueActionServlet, which does
the Torque.init() stuff.
But your error messages indicate a ClassNotFound error, not a Torque
initialization error.
Could it be that you don't have the classes in your WEB-INF directory?
In particular, make sure you have the classes in
the com.lawson.is.biztracker.objectmodel.map
package.
Also, how does InitServlet get called? In your web.xml, what's the base
class for your servlet? It should be a descendant of ActionServlet to
have it work with Struts - which means that it can't use your
InitServlet class (unless you make that descended from ActionServlet.)
-Peter
On Tue, 2002-10-15 at 14:21, Bob wrote:
> I'm new to Torque and trying to get it working as my
> persistence engine with a struts application. I can get
> torque to generate all my classes and the database schema
> and even compile my entire project. However, the second I
> try to run a struts action that has a Torque lookup,
> everything explodes. I have set up an InitServlet per some
> of the other messages on this list, but the servlet keeps
> failing to start. I'm not sure if Torque pukes because the
> servlet won't init, or if the servlet won't init because
> Torque pukes. An interesting catch-22. Anybody with some
> experience want to offer any thoughts? Code below.
>
> Thanks in Advance,
>
> Bob
>
>
>
>
> Here's my InitServlet (Again, as posted here before):
>
> package com.mypackage;
>
>
> import org.apache.torque.Torque;
>
> import javax.servlet.*;
> import javax.servlet.http.*;
>
>
> /**
> * Title:
> * Description:
> * Copyright: Copyright (c) 2002
> * Company:
> * @author
> * @version 1.0
> */
>
>
>
> public class InitServlet extends HttpServlet {
>
> // Properties
> private int debug = 0;
>
> public void init() throws ServletException {
> String value;
> value = getServletConfig().getInitParameter("debug");
> try {
> debug = Integer.parseInt(value);
> }
> catch (Throwable t) {
> debug = 0;
> }
> log("Initializing Torque ...");
> try {
> String propFileName =
> getServletConfig().getInitParameter("config");
> if( propFileName==null ) {
> propFileName="WEB-INF/Torque.properties";
> }
> String propFile =
> getServletContext().getRealPath(propFileName);
> System.out.println("\n\n\n\n\n Starting Torque
> Initialization... \n\n\n\n\n");
> log("Torque properties file: " + propFile);
> Torque.init(propFile);
> System.out.println("\n\n\n\n\n Torque Initialized
> \n\n\n\n\n");
> }
> catch(Exception e){
> System.out.println("\n\n\n\n\n Torque Servlet Yacked
> \n\n\n\n\n");
> throw new ServletException(e.getMessage());
> }
> }
> }
>
>
> And here's the relevant code of my struts action:
>
> try {
> Criteria crit = new Criteria();
> QueryList list = new QueryList();
> list.setResults(CapitalPaymentPeer.doSelect(crit));
>
> request.setAttribute("PAYMENTS", list);
> }
> catch (TorqueException e) {
> throw new ServletException(e.getMessage());
> }
>
>
> And here's the error I get in the torque log file that it
> writes:
>
> ERROR - BasePeer.MapBuilder failed trying to instantiate:
> com.lawson.is.biztracker.objectmodel.map.CapitalPaymentMapBuilder
> java.lang.ClassNotFoundException:
> com.lawson.is.biztracker.objectmodel.map.CapitalPaymentMapBuilder
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native
> Method)
> at
> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> at
> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> at
> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:120)
> at
> org.apache.torque.util.BasePeer.getMapBuilder(BasePeer.java:1982)
> at
>
>com.lawson.is.biztracker.objectmodel.BaseCapitalPaymentPeer.getMapBuilder(BaseCapitalPaymentPeer.java:57)
> at
>
>com.lawson.is.biztracker.objectmodel.BaseCapitalPaymentPeer.<clinit>(BaseCapitalPaymentPeer.java:128)
> at
>
>com.lawson.is.biztracker.actions.GoToCapitalPaymentsAction.perform(GoToCapitalPaymentsAction.java:38)
> at
> org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)
> at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
> at
> org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
> at
> org.apache.tomcat.core.Handler.service(Handler.java:286)
> at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> at
> org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
> at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
> at
>
>org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
> at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
> at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
> at java.lang.Thread.run(Thread.java:484)
>
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>