db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc BEGUIGNEAU <marc_beguign...@yahoo.fr>
Subject Re: torque and tomcat
Date Fri, 04 Jul 2003 06:45:24 GMT
Hi,

I am using the same versin as you (Tomcat 4.1.24 and
java 1.4.1_01) and everything work (with Oracle)

I have made an InitTorque servlet who is in charge to
initialize Torque at the same time to Struts. Here is
a cut of this servlet :

--------------------------------------------------
package com.istia.si;

import java.io.InputStream;
import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.*;
import javax.servlet.*;

import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.commons.configuration.Configuration;
import
org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.lang.*;

public class InitTorque extends HttpServlet {

	public void init(ServletConfig config) throws
ServletException {
		super.init(config);

		try {
			InputStream configStream =
getServletContext().getResourceAsStream(config.getInitParameter("config"));
			PropertiesConfiguration c = new
PropertiesConfiguration();
			c.load( configStream );
			Torque.init( c );
		}
		catch ( IOException e ) {
			throw new ServletException( e.toString() );
		}
		catch ( TorqueException e ) {
			throw new ServletException( e.toString() );
		}
	}
}
--------------------------------------------------


And the config in the web.inf file:

--------------------------------------------------
(....)
<!-- Servlet d'initialisation de Torque -->
  <servlet>
    <servlet-name>InitTorque</servlet-name>
   
<servlet-class>com.istia.si.InitTorque</servlet-class>
    <init-param>
      <param-name>config</param-name>
     
<param-value>/WEB-INF/Torque.properties</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
  </servlet>
(....)
--------------------------------------------------

Note that this code is place after the declaration of
the Struts ActionServlet. I am not sure if placing
this before or after the ActionServlet has an effect
but after work, it's sure!

And to comment your solution, I think your servlet is
good but you don't indicate to your servlet the
init-param (the Torque.properties file), I think this
is your problem.

And to finish, I'm actually working on the migration
of my existing db from Oracle to postgresql and I have
some problem (evrything worked fine with Oracle). Can
you post or mail a cut of your configuration file
(xx-schema.xml and Torque.properties file)? This will
be very nice!

Hope my solution help you!

Regards

Marc




 --- Brendan McCarthy <bp_mccarthy@iprimus.com.au> a
écrit : > 
> Hi,
> 
> I am trying to use torque to connect to my
> postgresql database using  
> tomcat-4.1.24 and java 1.4.1_01.
> 
> The expection being thrown seems to indicate that
> torque cannot load  
> the org.postgresql.Driver class, but the rest of my
> code can access it  
> fine. It is even available to the InitServerlet. I
> have tried every  
> location that I can think of for the pgsql driver
> class file.
> 
> thanks in advance,
> -Brendan McCarthy
> 
> 
> I am initializing torque using an InitServlet:
> 
> package com.wyware.wyzilla.utils;
> 
> import org.apache.torque.Torque;
> 
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> 
> public class InitServlet extends HttpServlet
> {
> 
>          public void init(ServletConfig config)
> throws ServletException
>          {
>                  super.init(config);
>                  try
>                  {
>                          Class.forName(
> "org.postgresql.Driver" );
>                          String propFileName =  
> config.getInitParameter("propFile");
>                          if( propFileName==null )
>                          {
>                                   
> propFileName="WEB-INF/Torque.properties";
>                          }
>                          String propFile =  
> getServletContext().getRealPath(propFileName);
>                          Torque.init(propFile);
>                  }
>                  catch(Exception e)
>                  {
>                          throw new ServletException(
> e ); //line 28
>                  }
>          }
> }
> 
> with the web.xml entry:
> 
>          <servlet>
>                 
> <servlet-name>initServlet</servlet-name>
>                   
>
<servlet-class>com.wyware.wyzilla.utils.InitServlet</servlet-class>
>                 
> <load-on-startup>3</load-on-startup>
>          </servlet>
> 
> 
> Here's the exception that tomcat is giving me:
> 
> 
> rethrown as org.apache.torque.TorqueException
>          at  
>
org.apache.torque.Torque.initDataSourceFactories(Torque.java:331)
>          at
> org.apache.torque.Torque.initialize(Torque.java:237)
>          at
> org.apache.torque.Torque.init(Torque.java:406)
>          at
> org.apache.torque.Torque.init(Torque.java:386)
>          at  
>
com.wyware.wyzilla.utils.InitServlet.init(InitServlet.java:24)
>          at
>
org.apache.catalina.core.StandardWrapper.loadServlet(Unknown
>  
> Source)
>          at
>
org.apache.catalina.core.StandardWrapper.load(Unknown
> Source)
>          at  
>
org.apache.catalina.core.StandardContext.loadOnStartup(Unknown
> Source)
>          at
>
org.apache.catalina.core.StandardContext.start(Unknown
>  
> Source)
>          at  
>
org.apache.catalina.core.ContainerBase.addChildInternal(Unknown
> Source)
>          at
>
org.apache.catalina.core.ContainerBase.addChild(Unknown
>  
> Source)
>          at
>
org.apache.catalina.core.StandardHost.addChild(Unknown
>  
> Source)
>          at  
>
org.apache.catalina.core.StandardHostDeployer.install(Unknown
> Source)
>          at
>
org.apache.catalina.core.StandardHost.install(Unknown
> Source)
>          at
>
org.apache.catalina.servlets.ManagerServlet.install(Unknown
>  
> Source)
>          at
>
org.apache.catalina.servlets.ManagerServlet.doGet(Unknown
>  
> Source)
>          at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java)
>          at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java)
>          at  
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown
> 
>   Source)
>          at  
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown
> Source)
>          at
>
org.apache.catalina.core.StandardWrapperValve.invoke(Unknown
>  
> Source)
>          at  
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> 
> nvokeNext(Unknown Source)
>          at
>
org.apache.catalina.core.StandardPipeline.invoke(Unknown
>  
> Source)
>          at
>
org.apache.catalina.core.ContainerBase.invoke(Unknown
> Source)
>          at
>
org.apache.catalina.core.StandardContextValve.invoke(Unknown
>  
> Source)
>          at  
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> 
> nvokeNext(Unknown Source)
>          at  
>
org.apache.catalina.authenticator.AuthenticatorBase.invoke(Unknown
>  
> Source)
>          at  
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> 
> nvokeNext(Unknown Source)
>          at
>
org.apache.catalina.core.StandardPipeline.invoke(Unknown
>  
> Source)
>          at
>
org.apache.catalina.core.ContainerBase.invoke(Unknown
> Source)
>          at
>
org.apache.catalina.core.StandardContext.invoke(Unknown
>  
> Source)
>          at
>
org.apache.catalina.core.StandardHostValve.invoke(Unknown
>  
> Source)
>          at  
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> 
> nvokeNext(Unknown Source)
>          at  
>
org.apache.catalina.valves.ErrorDispatcherValve.invoke(Unknown
> Source)
>          at  
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> 
> nvokeNext(Unknown Source)
>          at
>
org.apache.catalina.valves.ErrorReportValve.invoke(Unknown
>  
> Source)
>          at  
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> 
> nvokeNext(Unknown Source)
> 
=== message truncated === 

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

Mime
View raw message