-->
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: load is not valid without active transaction
PostPosted: Wed Jan 17, 2007 9:26 am 
Newbie

Joined: Wed Jan 10, 2007 1:30 pm
Posts: 3
Hi,

I have been trying to get JTA working with jrun4 using the following configs. it seems that the way I am creating my session has nothing to do with my transactions. Hence the problems shown. My guess is that I am creating them in two different ways. E.G on the threadlocal. How do I get a session that is created using JTA that will bind to my transaction?

More info. I am trying to follow the following. and am trying to follow the same example. i guess I must be creating my sessionfactory incorrectly as that has not bound to my currentSession. Any help would be appreciated.

Transaction demarcation with JTA

Code:
try {
    UserTransaction tx = (UserTransaction)new InitialContext()
                            .lookup("java:comp/UserTransaction");
                           
    tx.begin();

    // Do some work
    factory.getCurrentSession().load(...);
    factory.getCurrentSession().persist(...);

    tx.commit();
}
catch (RuntimeException e) {
    tx.rollback();
    throw e; // or display error message
}





version 3.2 of hibernate

Code:

        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
       
        <property name="hibernate.connection.datasource">HARMONY</property>
       
       
        <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JRun4TransactionManagerLookup</property>
      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
      
      
      
      <property name="hibernate.jta.UserTransaction">java:comp/UserTransaction</property>
       
       
        <property name="current_session_context_class">thread</property>
        <property name="hibernate.show_sql">true</property>





Code:

UserTransaction tx = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
            
tx.begin();
         
SysSecurityLogin login = (SysSecurityLogin) HibernateUtil.getSessionFactory().getCurrentSession().load(SysSecurityLogin.class, loginId);
         
tx.commit();




Code:

org.hibernate.HibernateException: load is not valid without active transaction
        at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
        at $Proxy2.load(Unknown Source)
        at net.olas.collaboration.BO.SysSecurityLoginGW.getLastName(Unknown Source)
        at jrun__user__test2ejspe._jspService(jrun__user__test2ejspe.java:59)
        at jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
        at jrun.jsp.JSPServlet.service(JSPServlet.java:119)
        at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
        at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
        at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
        at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
        at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
        at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
        at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
org.hibernate.HibernateException: load is not valid without active transaction
        at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
        at $Proxy2.load(Unknown Source)
        at net.olas.collaboration.BO.SysSecurityLoginGW.getLastName(Unknown Source)
        at jrun__user__test2ejspe._jspService(jrun__user__test2ejspe.java:59)
        at jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
        at jrun.jsp.JSPServlet.service(JSPServlet.java:119)
        at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
        at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
        at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
        at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
        at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
        at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
        at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
01/17 13:11:01 error load is not valid without active transaction
org.hibernate.HibernateException: load is not valid without active transaction
        at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
        at $Proxy2.load(Unknown Source)
        at net.olas.collaboration.BO.SysSecurityLoginGW.getLastName(Unknown Source)
        at jrun__user__test2ejspe._jspService(jrun__user__test2ejspe.java:59)
        at jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
        at jrun.jsp.JSPServlet.service(JSPServlet.java:119)
        at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
        at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
        at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
        at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
        at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
        at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
        at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

org.hibernate.HibernateException: load is not valid without active transaction
        at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
        at $Proxy2.load(Unknown Source)
        at net.olas.collaboration.BO.SysSecurityLoginGW.getLastName(Unknown Source)
        at jrun__user__test2ejspe._jspService(jrun__user__test2ejspe.java:59)
        at jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
        at jrun.jsp.JSPServlet.service(JSPServlet.java:119)
        at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
        at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
        at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
        at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
        at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
        at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
        at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
org.hibernate.HibernateException: load is not valid without active transaction
        at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
        at $Proxy2.load(Unknown Source)
        at net.olas.collaboration.BO.SysSecurityLoginGW.getLastName(Unknown Source)
        at jrun__user__test2ejspe._jspService(jrun__user__test2ejspe.java:59)
        at jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
        at jrun.jsp.JSPServlet.service(JSPServlet.java:119)
        at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
        at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
        at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
        at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
        at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
        at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
        at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
01/17 13:11:25 info Transaction rolled back on JDBC Connection from DataSource HARMONY
01/17 13:12:01 error load is not valid without active transaction
org.hibernate.HibernateException: load is not valid without active transaction
        at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
        at $Proxy2.load(Unknown Source)
        at net.olas.collaboration.BO.SysSecurityLoginGW.getLastName(Unknown Source)
        at jrun__user__test2ejspe._jspService(jrun__user__test2ejspe.java:59)
        at jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
        at jrun.jsp.JSPServlet.service(JSPServlet.java:119)
        at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
        at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
        at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
        at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
        at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
        at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
        at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)




[/code]


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.