PDA

View Full Version : CanNotCreateTransactionException



TonyA
Dec 14th, 2009, 09:19 AM
I am upgrading my projects application from
Spring 1.2.5 --> Spring 2.5.6
and
Hibernate 3.0.5 --> Hibernate 3.3.2

I can get to the application log in screen. When I log in I get this error message. I am also hand typing in the error message, so I hope I did not make any mistakes

Thanks

org.springframework.transaction.CannotCreateTransa ctionException: Could not open Hibernate Session for transaction; nested exception is java.lang. IllegalArgumentException: No Connection specified
at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doBegin(HibernateTransactionManager.j ava:599)

Caused by: java.lang.IllegalArgumentException: No Connection specified
at org.springframework.util.Assert.noNull(Assert.java 112)
at org.springframework.jdbc.datasource.DataSourceUtil s.prepareConnectionForTransaction(DataSourceUtils. java:149)
at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doBegin(HibernateTransactionManager.j ava:511)

fdemilde
Dec 15th, 2009, 05:46 AM
please provide config files within code tags

TonyA
Dec 15th, 2009, 08:30 AM
Thanks for any help you can give me.

We are running on tomcat 6.0.16
Here are some of my my C:\tomcat\lib JAR files
commons-logging-1.0.4.jar
log4j-1.2.15.jar
ojdbc14-10.2.0.1.0.jar
slf4j-api-1.5.8.jar
slf4j-log4j12-1.5.0.jar

Here are some of the C:\tomcat\webapps\myProject\web-inf\lib JAR files
antlr-2.7.6.jar
asm-1.5.3.jar
cglib-2.1.jar
commons-collections-3.1.jar
ehcache-1.1.jar
hibernate-3.3.2.jar
javassit-3.9.0.jar
jta-1.1.jar
log4j-1.2.15.jar
spring-2.5.6.jar

Here is some of my web.xml file
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-database.xml,
/WEB-INF/applicationContext-service.xml,
/WEB-INF/applicationContext-service-myProject.xml,
/WEB-INF/applicationContext-hibernate.xml,
/WEB-INF/applicationContext-myProject.xml
</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>

</web-app>


Here is the applicationContext-database.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/myProject"/>
</bean>
</beans>

Here is the applicationContext-hibernate.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<import resource="applicationContext-database.xml"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFac toryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>com/myProject/Worker.htm.xml</value>
....
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.bytecode.provider">javassit</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.connection.release mode">on_close</prop>
<prop key="hibernate.show.sql">false</prop>
<prop key="hibernate.max_fetch_depth">0</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransa ctionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>

Here is my applicationContext-service.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<import resource="applicationContext-hibernate.xml"/>
<bean id="autoProxyCreator2" class="org.springframework.aop.framework.autoproxy.BeanNa meAutoProxyCreator">
<property name="interceptorNames'>
<list>
<idref bean="transactionInterceptor"/>
<idref bean="maximoTransactionInterceptor"/>
</list>
</property>
<property name="beanNames">
<list>
<idref bean="userManager"/>
</list>
</property>
</bean>
<bean id="ldapGetterAdvistor" class="org.springframework.aop.support.RegexpMethodPointc utAdvisor">
<property name="advice">
<ref local="ldapSessionMethodInterceptor"/>
</property>
<property name="patterns">
<list>
<value>.*get.*</value>
</list>
</property>
</bean>
<bean id="ldapAutoProxy" class="org.springframework.aop.framework.BeanNameAutoProx yCreator">
<property name="interceptorNames">
<list>
<idref bean="ldapGetterAdvisor"/>
</list>
</property>
<property name="beanNames">
<list>
<idref bean="userServiceDAO"/>
</list>
</property>
</bean>
</beans>

Finally the applicationContext-service-myProject.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<import resource="applicationContext-hibernate.xml"/>
<bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNa meAutoProxyCreator">
<property name="interceptorNames'>
<list>
<idref bean="transactionInterceptor"/>
</list>
</property>
<property name="beanNames">
<list>
<idref bean="personManager"/>
<idref bean="equipmentManager"/>
</list>
</property>
</bean>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.Transa ctionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributeSource">
<ref bean="transactionAttributeSource"/>
</property>
</bean>
<bean id="transactionAttributeSource" class="org.springframework.transaction.interceptor.NameMa tchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="get*">PROPAGATION REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans>