Hi everybody
I'm sorry to ask this question but it's now 2 days I'm fighting to get JNDI provided by Tomcat and hibernate working together.
First I create a JNDI Context with tomcat in my context
Code:
<Resource name="jdbc/crm"
auth="Container" type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
user="root"
password="457yuuio"
driverClassName="org.gjt.mm.mysql.Driver"
url="jdbc:mysql://localhost/crm?user=root&password=457yuuio"
maxWait="-1" removeAbandoned="true" removeAbandonedTimeout="3"
logAbandoned="false"/>
This work fine when I use a code like this one
Code:
Context ctx = new InitialContext();
if(ctx == null ) throw new Exception("Boom - No Context");
ds = (DataSource)ctx.lookup("java:comp/env/jdbc/crm");
Now here is the part of my hibernate.cfg.xml to work with JNDI
Code:
<property name="connection.datasource">java:comp/env/jdbc/crm</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLMyISAMDialect</property>
But When I try to get the SessionFactory Using this code
Code:
sessionFactory = configuration.configure().buildSessionFactory();
I got this error
Code:
Building SessionFactory failed :
NoClassDefException : javax/transaction/Synchronization
I really don't know what to do for this
Any help would be greatly appreciated.