Here are the 3 key parts to the error we get when trying to use Hibernate with Tomcats JNDI feature:
Cannot create JDBC driver of class '' for connect URL 'null'
Caused by: java.sql.SQLException: No suitable driver
net.sf.hibernate.exception.GenericJDBCException: Cannot open connection
Tomcats read only JNDI conetxt works just fine. The following code satisfied me in this regard:
<%
String success = null;
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/ora");
success = "yayyy";
System.out.println("Success: " + ds.toString());
}
catch (Exception e) {
success = "oh shit - here we go again";
}
%>
<%= success %>
Here is the relevant portion of sever.xml. To rule out a whole catagory of post responses, we have tried having the location of this file in both the web application's own context.xml and in the global server.xml.
<resource name="jdbc/ora" auth="container" type="javax.sql.DataSource">
<resourceParams>
<paramter>
<name>driverClassName</name>
<value>oracle.jdbc.OracleDriver</value>
</paramter>
<paramter>
<name>url</name>
<value>jdbc

racle:thin:@localhost:1521

RCL</value>
</paramter>
<paramter>
<name>username</name>
<value>store</value>
</paramter>
<paramter>
<name>password</name>
<value>store_password</value>
</paramter>
<paramter>
<name>maxActive</name>
<value>20</value>
</paramter>
<paramter>
<name>maxIdle</name>
<value>30000</value>
</paramter>
<paramter>
<name>maxWait</name>
<value>100</value>
</paramter>
</resourceParams>
</resource>
As you would expect, the relevant section of web.xml ammended with a few variations of the following (With and without 'sharable' etc):
<resource-ref>
<res-ref-name>jdbc/ora</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Here is the hibernate.cfg. This has been tried with the session-factory name attribute removed and with various other combinations of elements - this should be all that is needed however.:
<session-factory name="java:comp/env/hibernate/SessionFactory">
<!-- properties java:/comp/env/-->
<property name="connection.datasource">java:/comp/env/jdbc/ora</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle</property>
<property name="show_sql">false</property>
<!-- mapping files -->
<mapping resource="hiberTest/persisted/assessment.hbm.xml"/>
<mapping resource="hiberTest/persisted/testtaker.hbm.xml"/>
<mapping resource="hiberTest/persisted/testtakerAssessment.hbm.xml"/>
</session-factory>
There are no conflicts, typos, or clashing .properties files on the classpath, or anything in the world that should prevent Hibernate using our JNDI wired DataSource. I fully expect any and every response to reiterate something we have already tried, and tried with at tleast 2 tomcat versions on more than 4 different occasions in isolation and in combination with other suggestions. Pessimistic, I know. We said we would give the issue a month and then drop Hibernate for something that will work as we need it too - that gives us appox 3 days to sort it out. Its not looking good.