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.  [ 2 posts ] 
Author Message
 Post subject: obtaining a separate transaction context in thread
PostPosted: Tue Oct 19, 2004 10:35 pm 
Newbie

Joined: Thu Jan 08, 2004 8:53 pm
Posts: 7
Location: massachusetts
can someone please help me - I have a JBoss (3.2.3) service with a managed datasource. WIthin this service i need to run one or more threads. The threads need to run with their own sessions and transaction contexts. Can i use the same session factory for all the threads but obtain a different transaction context? I don't want the threads to enlist in the same transaction - so i don't think i can use (new InitialContext()).lookup("UserTransaction") to obtain a UserTransaction in each thread, but if i use the (managed) session factory to get a session if i then try to 'beginTransaction' i get the following error:
beginTransaction on session failed, no UserTransaction manager, embedded exception: net.sf.hibernate.TransactionException: Could not register Synchronization [Could not register Synchronization]

So how do i create a new session and begin a new transaction in each thread? Do i have to configure an unmanaged session factory? and manage my own session pool?


Top
 Profile  
 
 Post subject: Re: obtaining a separate transaction context in thread
PostPosted: Wed Oct 20, 2004 1:56 pm 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
Brassrat wrote:
can someone please help me - I have a JBoss (3.2.3) service with a managed datasource. WIthin this service i need to run one or more threads. The threads need to run with their own sessions and transaction contexts. Can i use the same session factory for all the threads but obtain a different transaction context? I don't want the threads to enlist in the same transaction - so i don't think i can use (new InitialContext()).lookup("UserTransaction") to obtain a UserTransaction in each thread, but if i use the (managed) session factory to get a session if i then try to 'beginTransaction' i get the following error:
beginTransaction on session failed, no UserTransaction manager, embedded exception: net.sf.hibernate.TransactionException: Could not register Synchronization [Could not register Synchronization]

So how do i create a new session and begin a new transaction in each thread? Do i have to configure an unmanaged session factory? and manage my own session pool?


Why not to put your business logic into SLSB and call it from your service? It will provide you both transaction management and hibernate session management, isn't it exactly what you need?


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

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.