|
From: Ken K. <kk...@kk...> - 2003-06-10 20:54:25
|
Help anybody,
I'm having some difficulty with getting a Tomcat 4.1.18 pooled
connection DataSource working for petclinic demo :=(.
I have set up my applicationContext.xml to support configuration of a
DataSource bean for either Mysql or Hsql. Both jdbc drivers are deployed
in /WEB-INF/lib. You will notice that there are 2 beans defined for each
database but only 1 DataSource bean is used at any given time. For each
database there is a DriverManagerDataSource version both of which work
well. For each database there is also a JndiObjectFactoryBean version. I
have defined the Jndi objects in petclinic.xml which is deployed in the
Tomcat webapps dir. The pooled Mysql version works fine. The pooled Hsql
version throws an exception when first accessed because it can't load
the driver class. I have checked the className spec, etc. again and
again and have not been able to figure out why it won't load. The
relevant log output follows:
blah,blah,blah ...
2003-06-10 13:40:12 ContextConfig[/petclinic_demo_tutorial-1.0]:
Adding path '/WEB-INF/lib/hsqldb.jar'
blah,blah,blah ...
2003-06-10 13:40:13 ContextConfig[/petclinic_demo_tutorial-1.0]: Pipline
Configuration:
2003-06-10 13:40:13 ContextConfig[/petclinic_demo_tutorial-1.0]:
org.apache.catalina.core.StandardContextValve/1.0
2003-06-10 13:40:13 ContextConfig[/petclinic_demo_tutorial-1.0]:
======================
2003-06-10 13:40:13
NamingContextListener[/Standalone/localhost/petclinic_demo_tutorial-1.0]:
Creating JNDI naming context
2003-06-10 13:40:13
NamingContextListener[/Standalone/localhost/petclinic_demo_tutorial-1.0]:
Resource parameters for jdbc/petclinicHSQL =
ResourceParams[name=jdbc/petclinicHSQL,
parameters={url=jdbc:hsqldb:hsql://localhost:9001, maxIdle=10,
maxActive=50, driverClassName=org.hsqldb.jdbcDriver, maxWait=10000,
removeAbandoned=true, username=sa,
factory=org.apache.commons.dbcp.BasicDataSourceFactory,
logAbandoned=true, removeAbandonedTimeout=60, password=}]
2003-06-10 13:40:13
NamingContextListener[/Standalone/localhost/petclinic_demo_tutorial-1.0]:
Adding resource ref jdbc/petclinicHSQL
2003-06-10 13:40:13
NamingContextListener[/Standalone/localhost/petclinic_demo_tutorial-1.0]:
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=url,content=jdbc:hsqldb:hsql://localhost:9001},{type=maxIdle,content=10},{type=maxActive,content=50},{type=driverClassName,content=org.hsqldb.jdbcDriver},{type=maxWait,content=10000},{type=removeAbandoned,content=true},{type=username,content=sa},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=logAbandoned,content=true},{type=removeAbandonedTimeout,content=60},{type=password,content=}]
2003-06-10 13:40:13
NamingContextListener[/Standalone/localhost/petclinic_demo_tutorial-1.0]:
Resource parameters for jdbc/petclinicMYSQL =
ResourceParams[name=jdbc/petclinicMYSQL,
parameters={url=jdbc:mysql://localhost:3306/petclinic?autoReconnect=true,
maxIdle=10, maxActive=50, driverClassName=org.gjt.mm.mysql.Driver,
maxWait=10000, removeAbandoned=true, username=pc,
factory=org.apache.commons.dbcp.BasicDataSourceFactory,
logAbandoned=true, removeAbandonedTimeout=60, password=pc}]
2003-06-10 13:40:13
NamingContextListener[/Standalone/localhost/petclinic_demo_tutorial-1.0]:
Adding resource ref jdbc/petclinicMYSQL
2003-06-10 13:40:13
NamingContextListener[/Standalone/localhost/petclinic_demo_tutorial-1.0]:
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=url,content=jdbc:mysql://localhost:3306/petclinic?autoReconnect=true},{type=maxIdle,content=10},{type=maxActive,content=50},{type=driverClassName,content=org.gjt.mm.mysql.Driver},{type=maxWait,content=10000},{type=removeAbandoned,content=true},{type=username,content=pc},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=logAbandoned,content=true},{type=removeAbandonedTimeout,content=60},{type=password,content=pc}]
2003-06-10 13:40:13
NamingContextListener[/Standalone/localhost/petclinic_demo_tutorial-1.0]:
Resource parameters for UserTransaction = null
2003-06-10 13:40:13 StandardManager[/petclinic_demo_tutorial-1.0]:
Seeding random number generator class java.security.SecureRandom
2003-06-10 13:40:13 StandardManager[/petclinic_demo_tutorial-1.0]:
Seeding of random number generator has been completed
2003-06-10 13:40:13 StandardContext[/petclinic_demo_tutorial-1.0]:
Posting standard context attributes
2003-06-10 13:40:13 StandardContext[/petclinic_demo_tutorial-1.0]:
Configuring application event listeners
2003-06-10 13:40:13 StandardContext[/petclinic_demo_tutorial-1.0]:
Configuring event listener class
'com.interface21.web.context.ContextLoaderListener'
2003-06-10 13:40:13 StandardContext[/petclinic_demo_tutorial-1.0]:
Sending application start events
2003-06-10 13:40:14 StandardContext[/petclinic_demo_tutorial-1.0]:
Exception sending context initialized event to listener instance of
class com.interface21.web.context.ContextLoaderListener
java.sql.SQLException: Cannot load JDBC driver class 'org.hsqldb.jdbcDriver'
at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:529)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312)
at
com.interface21.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:146)
at
com.interface21.jdbc.core.JdbcTemplate.doWithResultSetFromPreparedQuery(JdbcTemplate.java:279)
at com.interface21.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:264)
at com.interface21.jdbc.object.SqlQuery.execute(SqlQuery.java:121)
at com.interface21.jdbc.object.SqlQuery.execute(SqlQuery.java:129)
at petclinic.dao.ClinicJdbcDAO.getVets(Unknown Source)
at petclinic.ClinicImpl.afterPropertiesSet(Unknown Source)
at
com.interface21.beans.factory.support.AbstractBeanFactory.callLifecycleMethodsIfNecessary(AbstractBeanFactory.java:429)
at
com.interface21.beans.factory.support.AbstractBeanFactory.createBean(AbstractBeanFactory.java:121)
at
com.interface21.beans.factory.support.AbstractBeanFactory.getSharedInstance(AbstractBeanFactory.java:167)
at
com.interface21.beans.factory.support.AbstractBeanFactory.getBeanInternal(AbstractBeanFactory.java:234)
at
com.interface21.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:215)
at
com.interface21.beans.factory.support.ListableBeanFactoryImpl.preInstantiateSingletons(ListableBeanFactoryImpl.java:224)
at
com.interface21.beans.factory.support.XmlBeanFactory.loadBeanDefinitions(XmlBeanFactory.java:225)
at
com.interface21.beans.factory.support.XmlBeanFactory.<init>(XmlBeanFactory.java:160)
at
com.interface21.context.support.AbstractXmlApplicationContext.parseDocument(AbstractXmlApplicationContext.java:87)
at
com.interface21.context.support.AbstractXmlApplicationContext.refreshBeanFactory(AbstractXmlApplicationContext.java:59)
at
com.interface21.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:208)
at
com.interface21.web.context.support.XmlWebApplicationContext.setServletContext(XmlWebApplicationContext.java:121)
at
com.interface21.web.context.ContextLoader.initContext(ContextLoader.java:56)
at
com.interface21.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:20)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3269)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3598)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:821)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579)
at
org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer.java:529)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:228)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:260)
at org.apache.commons.digester.Digester.endElement(Digester.java:1036)
at
org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:585)
at
org.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java:647)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1008)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1469)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at org.apache.commons.digester.Digester.parse(Digester.java:1514)
at
org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:335)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:803)
at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:452)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:409)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:879)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:368)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1196)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
at
org.apache.catalina.core.StandardService.start(StandardService.java:497)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:2189)
at
org.apache.catalina.startup.CatalinaService.start(CatalinaService.java:273)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.catalina.startup.BootstrapService.start(BootstrapService.java:245)
at
org.apache.catalina.startup.BootstrapService.main(BootstrapService.java:307)
2003-06-10 13:40:14 StandardContext[/petclinic_demo_tutorial-1.0]:
Context startup failed due to previous errors
The hsqldb.jar path is added as shown in the log, the Jndi objects are
created, the className is identical to that specified in the
DriverManagerDataSource version, and the named class is in the hsqldb.jar.
So why won't it load ???
I have attached the configuration files. Any help would be greatly
appreciated.
BTW, I'm nearly complete with the functionality I'm going to implement
in version 1. I will then post the code for anybody who wants to make
comments or suggestions. I will also start decomposing it into stages
and writing accompanying tutorial text. I hope to be finished before the
TSS Symposium.
Regards,
Ken Krebs
|