What is in tomat's lib directory? And what's in the <resource-ref> ... </resource-ref> section of your web.xml?

Commenting on your resource definition below, remove autoReconnect=true as it's not recommended by the mysql folks. Add validationQuery="select 1" to have the pool test connections on borrow. This works a *lot* better than the autoReconnect parameter.

In general your error "Cannot create JDBC driver of class '' for connect URL 'null'" generally means there's some misconfiguration in either your context xml file (maybe the one you have below isn't being used?) or WEB-INF/web.xml file.

--David

Fabien D. wrote:

Hi everybody,

I'm using tomcat6 and  trying to use datasource for mysql connexion (and
hibernate). I have looked to the tomcat 6 official documentation, and in the
$CATALINA_HOME/conf/context.xml, i have declared :
<Context
        path="/appWicket"
        reloadable="true">
        <Resource
name="jdbc/hibernate" auth="Container"
          type="javax.sql.DataSource"
description="DB Connection" driverClass="com.mysql.jdbc.Driver" jdbcUrl="jdbc:mysql://localhost:3306/opensource?autoReconnect=true" user="root" password="xxxx"/>
</Context>



In my hibernate.cfg.xml, I have done this (add the first line, to replace
the commented lines):
   <session-factory name="appWicketSession">
<property
name="connection.datasource">java:comp/env/jdbc/hibernate</property>

       <!--property
name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property-->
       <!--property name="hibernate.connection.password">admin</property-->
       <!--property
name="hibernate.connection.url">jdbc:mysql://localhost:3306/opensource</property-->
       <!--property name="hibernate.connection.username">xxxx</property-->

       <property name="bytecode.use_reflection_optimizer">false</property>
       <property name="c3p0.max_size">5</property>
       <property name="c3p0.min_size">3</property>
       <property name="c3p0.timeout">1800</property>
       <property name="current_session_context_class">thread</property>
       <property
name="dialect">org.hibernate.dialect.MySQLDialect</property>
       <property name="format_sql">true</property>
       <property name="show_sql">true</property>

When I try to launch the application, an error appears :

INFO [http-8080-1] (NamingHelper.java:26) - JNDI InitialContext
properties:{}
INFO [http-8080-1] (DatasourceConnectionProvider.java:61) - Using
datasource: java:comp/env/jdbc/hibernate
WARN [http-8080-1] (SettingsFactory.java:117) - Could not obtain connection
metadata
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of
class '' for connect URL 'null'
        at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
        at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at
org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
        at 
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
        at 
org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
        at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
        at com.mycompany.hibernate.HibernateUtil.<clinit>(Unknown Source)
        at com.mycompany.hibernate.GestionBDD.selectQuery(Unknown Source)
        at com.mycompany.middleware.CDataFromBDD.getListDomaine(Unknown Source)
        at com.mycompany.commun.PanelTreeView.<init>(Unknown Source)
        at com.mycompany.HomePage.initPanels(Unknown Source)
        at com.mycompany.HomePage.<init>(Unknown Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at
org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:149)
        at
org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:58)
        at
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:262)
        at
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:283)
        at
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:210)
        at
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
        at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1166)
        at org.apache.wicket.RequestCycle.step(RequestCycle.java:1243)
        at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1331)
        at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
        at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:363)
        at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
        at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
        at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
        at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
        at java.sql.DriverManager.getDriver(DriverManager.java:253)
        at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)

The log shows that it tries to load the datasource, and at the end of the
exception, we have this :
at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
and not com.mysql.jdbc.Driver.

I have put the jdbc driver in $CATALINA_HOME/lib/..

My researches on the net, don't help my to solve the problem, so if you can
help me thank you in advance :).


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to