Announcement Announcement Module
Collapse
No announcement yet.
Pre-bound JDBC Connection found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pre-bound JDBC Connection found

    Hi,

    I have following configuration...

    Code:
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    	<property name="jndiName" value="java:comp/env/jdbc/MyDS" />
    </bean>
    
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    	<property name="dataSource" ref="dataSource" />
    	<property name="mappingLocations">
    		<list>
    			<value>classpath:/mappings/myObject.hbm.xml</value>
    		</list>
    	</property>
    	<property name="hibernateProperties">
    		<props>
    			<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
    			<prop key="hibernate.show_sql">true</prop>
    			<prop key="hibernate.format_sql">true</prop>
    			<prop key="hibernate.jdbc.fetch_size">50</prop>
    			<prop key="hibernate.jdbc.batch_size">50</prop>
    			<prop key="hibernate.max_fetch_depth">3</prop>
    		</props>
    	</property>
    </bean>
    
    <!--hibernate transaction manager -->
    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    	<property name="sessionFactory">
    		<ref local="sessionFactory" />
    	</property>
    </bean>
    
    <!-- the transactional advice -->
    <tx:advice id="txAdvice" transaction-manager="txManager">
    	<!-- the transactional semantics... -->
    	<tx:attributes>
    		<tx:method name="get*" read-only="true" />
    		<tx:method name="test*" read-only="true" />
    		<!-- other methods use the default transaction settings (see below) -->
    		<tx:method name="*" />
    	</tx:attributes>
    </tx:advice>
    
    <!-- ensure that the above transactional advice runs for any execution -->
    <aop:config>
    	<aop:pointcut id="serviceOperation" expression="execution(* com.abc.service.*.*(..))" />
    	<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
    </aop:config>
    
    <!-- enable the configuration of transactional behavior based on annotations -->
    <tx:annotation-driven transaction-manager="txManager" />
    After I refresh the context dynamically using context.refresh(); my application stops working. It gives following error

    Code:
    org.springframework.transaction.IllegalTransactionStateException: Pre-bound JDBC Connection found! HibernateTransactionManager does not support running within DataSourceTransactionManager if told to manage the DataSource itself. It is recommended to use a single HibernateTransactionManager for all transactions on a single DataSource, no matter whether Hibernate or JDBC access.
    	org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:478)
    	org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
    	org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
    	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    Please let me know how to resolve it.

    Thanks

  • #2
    Hello

    After I refresh the context dynamically using context.refresh();
    my application stops working. It gives following error
    When you refresh the context, would be possible that some users are working with transactions just in such time?

    Is that the complete error stack trace?

    Comment


    • #3
      Thankyou dr_pompeii for your reply.

      In testing condition it was localhost where no other user was working with any transaction when context was refreshed. There are beans which are using this session factory, but when I refresh the context, I thought all the beans will get recreated and any old reference will no more hold. Is that right ? The stack trace is almost complete.

      Thanks

      Comment


      • #4
        In testing condition it was localhost where no other user was working with any transaction when context was refreshed.
        How are you refreshing the contect? (Post the source code). And why you are refreshing the context?

        Comment


        • #5
          Originally posted by dr_pompeii View Post
          How are you refreshing the contect? (Post the source code). And why you are refreshing the context?
          I also have this problem. And I did not refresh the context.

          Comment

          Working...
          X