-->
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.  [ 1 post ] 
Author Message
 Post subject: Two transactions in one session under JBoss
PostPosted: Thu Nov 20, 2008 3:53 pm 
Newbie

Joined: Thu Nov 20, 2008 3:30 pm
Posts: 1
I need to implement two transactions in one session and all the time I get “Session is Closed!” exception while beginning the second transaction.

I want to set the property hibernate.transaction.auto_close_session = false, but can not.

We have Hibernate configured as mbean under Jboss and all hibernate properties are configured in hibernate-service.xml
There is no corresponding mbean property for hibernate.transaction.auto_close_session

So I’m trying to set this property using ListenerInjector.
I read about it here: https://jira.jboss.org/jira/browse/HIBERNATE-17

But seems this InjectionListener is not called.

Here is hibernate-service.xml:

Code:


<server>

      <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">

            <attribute name="DatasourceName">java:/EPSDS</attribute>
            <attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
            <attribute name="SessionFactoryName">
            java:/hibernate/EPSDBHiberSessionFactory
        </attribute>

            <attribute name="CacheProviderClass">
            org.hibernate.cache.HashtableCacheProvider
        </attribute>

            <!-- attribute name="Hbm2ddlAuto">create-drop</attribute -->
            <attribute name="ShowSqlEnabled">true</attribute>

            <attribute name="ListenerInjector">com.sabre.eps.util.hibernate.MyInjectionListener</attribute>
      </mbean>


      <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=HibernateBackup">

                  <attribute name="DatasourceName">java:/EPSDSBackup</attribute>
                  <attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
                  <attribute name="SessionFactoryName">
                  java:/hibernate/EPSDBHiberBackupSessionFactory
              </attribute>
                  <attribute name="CacheProviderClass">
                  org.hibernate.cache.HashtableCacheProvider
              </attribute>
                  <!-- attribute name="Hbm2ddlAuto">create-drop</attribute -->
                  <attribute name="ShowSqlEnabled">true</attribute>
            <attribute name="ListenerInjector">com.sabre.eps.util.hibernate.MyInjectionListener</attribute>
      </mbean>

</server>



Here is MyInjectionListener:

Code:
package com.sabre.eps.util.hibernate;

import javax.management.ObjectName;
import org.hibernate.cfg.Configuration;
import org.jboss.deployment.DeploymentException;


public class MyInjectionListener implements org.jboss.hibernate.ListenerInjector {

      public void injectListeners(ObjectName arg0, Configuration config) throws DeploymentException {

            System.out.println("inject WORKS!!");
            config.setProperty("hibernate.transaction.auto_close_session", "false");

      }

}



I don’t see system out in the log.

Stacktrace of Session is Closed:
Code:
10:54:30,318 INFO  [STDOUT] Erasing profileId: 979863...(1/8)
10:54:30,318 ERROR [EraseProfiles] Error While Purging Profile. ProfileId=979863
org.hibernate.SessionException: Session is closed!
        at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
        at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1319)
        at com.sabre.eps.transformer.eraser.EraseProfiles.doProfilesDelete(EraseProfiles.java:263)
        at com.sabre.eps.transformer.eraser.EraseProfiles.deleteTravelerProfiles(EraseProfiles.java:107)
        at com.sabre.eps.transformer.eraser.EraseProfiles.deleteProfiles(EraseProfiles.java:75)
        at com.sabre.eps.services.purgeService.ProfilePurger.purge(ProfilePurger.java:113)
        at com.sabre.eps.services.purgeService.PurgeTimerService.handleTimeout(PurgeTimerService.java:120)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.tx.BMTInterceptor.handleStateless(BMTInterceptor.java:71)
        at org.jboss.ejb3.tx.BMTInterceptor.invoke(BMTInterceptor.java:131)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:108)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessContainer.callTimeout(StatelessContainer.java:175)
        at org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run(TimerImpl.java:561)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)     


Hibernate version: 3.2.5

JBoss version: 4.2.2

Name and version of the database you are using: Oracle 9 or 10


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

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.