abhi
abhi

Reputation: 820

org.hibernate.TransactionException: JDBC begin failed i

iam using spring with hibernate and my sql . i am getting this exception

at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:68)
 at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1290)
 at sun.reflect.GeneratedMethodAccessor114.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
 at $Proxy3.beginTransaction(Unknown Source)
 at com.iris.allofactor.data.dao.hibernate.HibernatePatientDao.getAllPatient(HibernatePatientDao.java:1419)
 at com.iris.allofactor.data.dao.impl.PatientBODaoImpl.getAllPatient(PatientBODaoImpl.java:256)
 at com.iris.allofactor.data.dao.facade.DaoFacadeImpl.getAllPatient(DaoFacadeImpl.java:2758)
 at sun.reflect.GeneratedMethodAccessor1125.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy2.getAllPatient(Unknown Source)
 at com.iris.allofactor.services.impl.AutoSyncServiceImpl.getAllPatient(AutoSyncServiceImpl.java:1561)
 at com.iris.allofactor.services.soap.impl.AutoSyncWebServiceImpl.getAllPatient(AutoSyncWebServiceImpl.java:441)
 at sun.reflect.GeneratedMethodAccessor1124.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
 at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
 at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
 at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
 at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
 at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
 at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
 at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
 at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
 at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Thread.java:619)

this is my c3p00l configaration

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  <!--  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >  -->
        <property name="driverClass"><value>${jdbc.driverClassName}</value></property> 
        <property name="jdbcUrl"><value>${jdbc.url}</value></property>
        <property name="user"><value>${jdbc.username}</value></property>
        <property name="password"><value>${jdbc.password}</value></property>
    </bean>

how can i resolve this issue ,is this issue have any thing related to c3pool .i am using c3pool with default values,do i need to specify any c3pool properties

Upvotes: 1

Views: 5688

Answers (3)

iosparkletree
iosparkletree

Reputation: 91

I was getting this error using the following configuration:

@PersistenceContext(type=PersistenceContextType.EXTENDED)  
@Autowired
private EntityManager entityManager;

I didn't realize that PersistenceContextType.EXTENDED wasn't thread safe. I believe the error must have been caused by multiple users accessing the application and the threads not being managed safely. When I changed my configuration to the following, deleting the PersistenceContextType.EXTENDED part:

@PersistenceContext
@Autowired
private EntityManager entityManager;

... then the error stopped happening for me.

Upvotes: 0

vtokmak
vtokmak

Reputation: 1506

Did you try this one?

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass"><value>${jdbc.driverClassName}</value></property> 
    <property name="jdbcUrl"><value>${jdbc.url}</value></property>
    <property name="user"><value>${jdbc.username}</value></property>
    <property name="password"><value>${jdbc.password}</value></property>
    <property name="validationQuery" value="SELECT 1"/>
    <property name="testOnBorrow" value="true"/>
</bean>

Upvotes: 2

Mark Bramnik
Mark Bramnik

Reputation: 42541

This can designate a connection to the db issue (maybe stale connection like described Here

In general since there is no much information here besides the exception itself, I would just place a breakpoint at the JDBCTransaction class and see why it fails.

Hope this helps

Upvotes: 0

Related Questions