Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to define a DataSource to an Oracle database on my Tomcat 6.0.

So, in conf/server.xml (yes, I know that this DataSource will be available for all the webapps in Tomcat, but it's not a problem here), I've set this Resource:

    <Resource name="hibernate/HibernateDS" auth="Container" type="javax.sql.DataSource"
        username="foo" password="bar"
        maxActive="50" maxIdle="10" validationQuery="select 1 from dual"/>

Then, in the web.xml of my application, I set a resource-ref element:

    <description>Hibernate Datasource</description>

Finally, as Hibernate is used to manage the database connection, I have a webapps/mywebapp/WEB-INF/classes/hibernate.cfg.xml that creates a session-factory using the JNDI DataSource:

        <property name="connection.datasource">java:comp/env/hibernate/HibernateDS</property>

However, when I start my Tomcat server, I get an error that says it could not create the

INFO  [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
INFO  [net.sf.hibernate.connection.DatasourceConnectionProvider] Using datasource: java:comp/env/hibernate/HibernateDS
INFO  [net.sf.hibernate.transaction.TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
INFO  [net.sf.hibernate.transaction.TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
WARN  [net.sf.hibernate.cfg.SettingsFactory] 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(
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(
        at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(
        at net.sf.hibernate.cfg.SettingsFactory.buildSettings(
        at net.sf.hibernate.cfg.Configuration.buildSettings(
Caused by: java.lang.NullPointerException
        at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(
        at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(
        at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(
        at java.sql.DriverManager.getDriver(
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(
        ... 11 more

Do you have any idea why Hibernate is not able to construct the session-factory? What is wrong in my configuration?

share|improve this question

Did you place the Oracle JDBC Jar in Tomcat's common/lib folder? Since Tomcat does not support Oracle DB connections out of the box, it may simply be missing the proper library.

Your resource definition and application configuration look fine to me.

share|improve this answer

your resource definition is missing attribute driverClassName

share|improve this answer
No it isn't. driverClassName="oracle.jdbc.OracleDriver". – EJP Aug 7 '12 at 10:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.