-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hanging @ beginTransaction()
PostPosted: Thu Jun 09, 2005 6:55 am 
Newbie

Joined: Thu Jun 09, 2005 6:41 am
Posts: 10
Hi,

I am using Hibernate within a JMS reciever. The code seems to hang when
we make a call to DatabaseUtil.beginTransaction().

I am using HibernateUtil present in caveatemptor-0.9.5 to make the
required database session activities.

I do not get any exception. It just hangs there! Not too sure if it has
anything to do with Threadlocal?

JMS Queue Reciever code:

Code:
        ... some code here

   //When the JMS queue recieves any message ...
   public void onMessage(Message msg) {
      try {
         if (msg instanceof TextMessage) {
            System.out.println(((TextMessage) msg).getText());
         } else if (msg instanceof ObjectMessage) {
            try {
               System.out.println("\t[onMessage] (1)");
               //Hangs after this
               //Calls HibernateUtil.beginTransaction(); shown below
               HibernateUtil.beginTransaction();

        ... code continues here



Code from HibernateUtil.java from caveatemptor-0.9.5

Code:
public static void beginTransaction()
   throws Exception {
   Transaction tx = (Transaction) threadTransaction.get();
   try {
      if (tx == null) {
         //Hangs here .....
         tx = getSession().beginTransaction();
         threadTransaction.set(tx);
      }
   } catch (HibernateException ex) {
      throw new Exception(ex);
   }
}



But a simple code like this works !

Code:
      
      MyBean MyBeanObj = new MyBean();
      HibernateUtil.beginTransaction();
      HibernateUtil.getSession().saveOrUpdate(MyBeanObj);
      HibernateUtil.commitTransaction();

I am lost here, can someone guide me?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2005 3:54 pm 
Newbie

Joined: Thu Jun 09, 2005 6:41 am
Posts: 10
Hi,

Can someone please help me with the above problem? I have searched,
experimented with other options and looked at resources on the internet and
found no way forward. Incase anyone of you have faced such porblems OR
any expert's views will help me to a great extent.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 5:14 pm 
Newbie

Joined: Thu Jun 09, 2005 6:41 am
Posts: 10
After a days work, i figured out the problem and as usual it was a a silly one. I had set the connection pool size to 1 and tried to open more than one session, which tried to use a second connection from the pool. Hence it went into a deadlock situation, hence the hanging.

Just increase the sie to a greater value, even during unit testing.

Just in case you face a similar problem, here is one solution i think might help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.