-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: JNDI Integration with Tomcat
PostPosted: Fri Feb 27, 2004 11:06 am 
Beginner
Beginner

Joined: Mon Dec 08, 2003 12:15 am
Posts: 47
Hello:

I am trying to get hibernate to use JNDI to obtain connections and it doens't work. I have included the stack trace below. Also, I am able to obtain the connection via a straight JNDI lookup. Also I will include my hibernate.cfg.xml below which is almost a copy and paste of the documentation.

I am using Tomcat 4.1.29 with mysql 4.0.17-standard

Any help is greatly appreciated.

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory name="java:comp/env">


<property name="connection.datasource">java:comp/env/securanceDatasource</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="use_outer_join">true</property>

<!-- Mapping files -->
<mapping resource="com/securance/vo/TechnologyVO.hbm.xml"/>
<mapping resource="com/securance/vo/ApTypeVO.hbm.xml"/>
<mapping resource="com/securance/vo/ApDetailLevelVO.hbm.xml"/>
<mapping resource="com/securance/vo/ApStepVO.hbm.xml"/>

</session-factory>

</hibernate-configuration>


Caught Exception
java.lang.UnsupportedOperationException
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:161)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:532)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:56)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:257)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3157)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3140)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2158)
at com.securance.dao.MySqlAPTypeDAO.getApTypes(MySqlAPTypeDAO.java:23)
at com.securance.audit.service.AuditToolServiceImpl.getAuditTypes(AuditToolServiceImpl.java:29)
at com.securance.web.servlet.InitServlet.init(InitServlet.java:57)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:823)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3422)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3623)
at org.apache.catalina.startup.HostConfig.checkWebXmlLastModified(HostConfig.java:614)
at org.apache.catalina.startup.HostConfig.run(HostConfig.java:854)
at java.lang.Thread.run(Thread.java:534)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 1:21 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
Not to discourage you, but this is exactly why I switched over to JBoss/Tomcat. I could never get Tomcat's JNDI to work. JBoss' JNDI was a cakewalk. http://www.hibernate.org/66.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 1:30 pm 
Beginner
Beginner

Joined: Mon Dec 08, 2003 12:15 am
Posts: 47
Hi Greg:

Unfortunately I don't have the luxury of switching over to jboss with tomcat.

I have however got my application to work after making some changes to my hibernate.cfg.xml file. What I had to do is fix the connection_datasource property to contain the right value, and the one that actually got me over the hump was adding this property:

<property name="hibernate.cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</property>

Take a look at the whole file below. I am up and running now :)

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>


<property name="connection.datasource">java:comp/env/jdbc/securanceDatasource</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="use_outer_join">true</property>
<property name="hibernate.cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</property>

<!-- Mapping files -->
<mapping resource="com/securance/vo/TechnologyVO.hbm.xml"/>
<mapping resource="com/securance/vo/ApTypeVO.hbm.xml"/>
<mapping resource="com/securance/vo/ApDetailLevelVO.hbm.xml"/>
<mapping resource="com/securance/vo/ApStepVO.hbm.xml"/>

</session-factory>

</hibernate-configuration>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.