db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brendan McCarthy <bp_mccar...@iprimus.com.au>
Subject torque and tomcat
Date Fri, 04 Jul 2003 00:04:16 GMT

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)
         at org.apache.catalina.core.StandardPipeline.invoke(Unknown  
Source)
         at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
         at org.apache.catalina.core.StandardEngineValve.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.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at  
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:59 
4)
         at  
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC 
onnection(Http11Protocol.java:392)
         at  
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:56 
5)
         at  
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool 
.java:619)
         at java.lang.Thread.run(Thread.java:536)
Caused by: org.apache.torque.TorqueException
         at  
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory.initCPDS(Jdbc2Poo 
lDataSourceFactory.java:140)
         at  
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory.initialize(Jdbc2P 
oolDataSourceFactory.java:108)
         at  
org.apache.torque.Torque.initDataSourceFactories(Torque.java:323)
         ... 48 more
Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at  
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav 
a:39)
         at  
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor 
Impl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at  
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUti 
ls.java:1789)
         at  
org.apache.torque.dsfactory.AbstractDataSourceFactory.setProperty(Abstra 
ctDataSourceFactory.java:121)
         at  
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory.initCPDS(Jdbc2Poo 
lDataSourceFactory.java:134)
         ... 50 more
Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
         at  
org.apache.catalina.loader.StandardClassLoader.loadClass(Unknown Source)
         at  
org.apache.catalina.loader.StandardClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:140)
         at  
org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS.setDriver(DriverAd 
apterCPDS.java:441)
         ... 57 more

Here's Torque.properties
---------------------------------------------------------------------
# $Id: Torque.properties,v 1.7 2002/09/11 13:53:26 stephenh Exp $
#
# This is the configuration file for Torque.
#
# Note that strings containing "," (comma) characters must backslash
# escape the comma (i.e. '\,')
#
# -------------------------------------------------------------------

torque.applicationRoot = .

# -------------------------------------------------------------------
#
#  L O G G I N G
#
# -------------------------------------------------------------------
# We use Log4J for all Torque logging and we embed the log4j
# properties within our application configuration.
# -------------------------------------------------------------------

# This first category is required and the category
# must be named 'default'. This is used for all logging
# where an explicit category is not specified.

log4j.category.org.apache.torque = ALL, org.apache.torque
log4j.appender.org.apache.torque = org.apache.log4j.FileAppender
log4j.appender.org.apache.torque.file = /var/log/wyzilla-torque.log
log4j.appender.org.apache.torque.layout = org.apache.log4j.PatternLayout
log4j.appender.org.apache.torque.layout.conversionPattern = %d [%t]  
%-5p %c - %m%n
log4j.appender.org.apache.torque.append = false

# -------------------------------------------------------------------
#
#  T O R Q U E  P R O P E R T I E S
#
# -------------------------------------------------------------------
# These are your database settings. Look in the
# org.apache.torque.pool.* packages for more information.
#
# The parameters to connect to the default database.  You MUST
# configure these properly.
# -------------------------------------------------------------------

torque.database.default=wyzilla
torque.database.wyzilla.adapter=postgresql

## Using torque's old pool
#torque.dsfactory.wyzilla.factory=org.apache.torque.dsfactory.TorqueData 
SourceFactory
#torque.dsfactory.wyzilla.pool.defaultMaxConnections=10
#torque.dsfactory.wyzilla.pool.maxExpiryTime=3600
#torque.dsfactory.wyzilla.pool.connectionWaitTimeout=10
#torque.dsfactory.wyzilla.connection.driver = org.postgresql.Driver
#torque.dsfactory.wyzilla.connection.url =  
jdbc:postgresql://localhost/wyzilla
#torque.dsfactory.wyzilla.connection.user = postgres
#torque.dsfactory.wyzilla.connection.password =

## Using Jdbc2Pool
torque.dsfactory.wyzilla.factory=  
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
torque.dsfactory.wyzilla.pool.defaultMaxActive=10
torque.dsfactory.wyzilla.pool.testOnBorrow=true
torque.dsfactory.wyzilla.pool.validationQuery=SELECT 1
torque.dsfactory.wyzilla.connection.driver =org.postgresql.Driver
torque.dsfactory.wyzilla.connection.url =  
jdbc:postgresql://localhost/wyzilla
torque.dsfactory.wyzilla.connection.user = postgres
torque.dsfactory.wyzilla.connection.password =


## Using jndi
#torque.dsfactory.bookstore.factory=org.apache.torque.dsfactory.JndiData 
SourceFactory
#torque.dsfactory.bookstore.jndi.path=jdbc/bookstore
#torque.dsfactory.bookstore.jndi.java.naming.factory.initial =  
org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.bookstore.jndi.java.naming.factory.url.pkgs =  
org.apache.naming

#torque.dsfactory.bookstore.datasource.classname=org.apache.torque.pool. 
TorqueClassicDataSource
#torque.dsfactory.bookstore.datasource.dataSourceName=jdbc/DBbookstore
#torque.dsfactory.bookstore.datasource.jndiEnvironment.java.naming.facto 
ry.initial = org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.bookstore.datasource.jndiEnvironment.java.naming.facto 
ry.url.pkgs = org.apache.naming
#torque.dsfactory.bookstore.datasource.defaultMaxConnections=10

## ConnectionPoolDataSource
#torque.dsfactory.bookstore.factory=org.apache.torque.dsfactory.JndiData 
SourceFactory
#torque.dsfactory.bookstore.jndi.path=jdbc/DBbookstore
#torque.dsfactory.bookstore.jndi.java.naming.factory.initial =  
org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.bookstore.jndi.java.naming.factory.url.pkgs =  
org.apache.naming
#torque.dsfactory.bookstore.datasource.classname=org.apache.commons.dbcp 
.cpdsadapter.DriverAdapterCPDS
#torque.dsfactory.bookstore.datasource.driver = org.gjt.mm.mysql.Driver
#torque.dsfactory.bookstore.datasource.url =  
jdbc:mysql://localhost:3306/torque
#torque.dsfactory.bookstore.datasource.user = user
#torque.dsfactory.bookstore.datasource.password = password

# Determines if the quantity column of the IDBroker's id_table should
# be increased automatically if requests for ids reaches a high
# volume.

torque.idbroker.cleverquantity=true

# Determines whether the managers cache instances of the business  
objects.
# And also whether the MethodResultCache will really cache results.

torque.manager.useCache = true


Mime
View raw message