Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Integration Spring3.2.2 with Hibernate4.1 Error

$
0
0
Hello ,
I use hibernate 4.1 and spring 3.2.2
i've this exception


Exception in thread "main" org.springframework.transaction.CannotCreateTransa ctionException: Could not open Hibernate Session for transaction; nested exception is java.lang.UnsupportedOperationException: Not supported by BasicDataSource
at org.springframework.orm.hibernate4.HibernateTransa ctionManager.doBegin(HibernateTransactionManager.j ava:514)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.getTransaction(AbstractPl atformTransactionManager.java:372)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.createTransactionIfNecessary(Tr ansactionAspectSupport.java:417)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.invokeWithinTransaction(Transac tionAspectSupport.java:255)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:94)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy13.sayHello(Unknown Source)
at test.com.gpao.service.Main.main(Main.java:27)
Caused by: java.lang.UnsupportedOperationException: Not supported by BasicDataSource
at org.apache.commons.dbcp.BasicDataSource.getConnect ion(BasicDataSource.java:1062)
at org.hibernate.service.jdbc.connections.internal.Da tasourceConnectionProviderImpl.getConnection(Datas ourceConnectionProviderImpl.java:141)
at org.hibernate.internal.AbstractSessionImpl$NonCont extualJdbcConnectionAccess.obtainConnection(Abstra ctSessionImpl.java:292)
at org.hibernate.engine.jdbc.internal.LogicalConnecti onImpl.obtainConnection(LogicalConnectionImpl.java :297)
at org.hibernate.engine.jdbc.internal.LogicalConnecti onImpl.getConnection(LogicalConnectionImpl.java:16 9)
at org.hibernate.engine.transaction.internal.jdbc.Jdb cTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.AbstractTrans actionImpl.begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.beginTransactio n(SessionImpl.java:1395)
at org.springframework.orm.hibernate4.HibernateTransa ctionManager.doBegin(HibernateTransactionManager.j ava:473)
... 8 more




my beans.xml is

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schem...ing-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/btest"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSes sionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.myapplication.entity" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.transaction.factory_class">org.hibe rnate.transaction.JDBCTransactionFactory</prop>
</props>
</property>
</bean>


<bean id="transactionManager" class="org.springframework.orm.hibernate4.Hibernat eTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>

<context:annotation-config />
<context:component-scan base-package="com.myapplication"/>

</beans>

Can any one help me please ???

Viewing all articles
Browse latest Browse all 297

Trending Articles