-->
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: Unable to resume previously suspended transaction error
PostPosted: Fri Jun 11, 2010 4:52 am 
Newbie

Joined: Mon Aug 14, 2006 3:14 am
Posts: 2
Hi All,

I am receiving the following error and I'm not sure why.

The code I am using is as follows;

Code:
@Stateless(name = "accountService")
public class AccountService implements AccountServiceLocal
{
    @PersistenceUnit(unitName = "persistence-local")
    EntityManagerFactory emf;

    @Override
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public void runAccount()
    {
       
        EntityManager manager = emf.createEntityManager();

        try
        {
            manager.getTransaction().begin();
            AccountNumber number = new AccountNumber();
            number.setAccountNumber(45987564);
            Card card = new Card();
            card.setAccountNumber(number);
            manager.persist(card);
            manager.getTransaction().commit();
        }
        finally
        {
            manager.close();
        }

    }
}


My persistence.xml file is as follows;

Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

  <persistence-unit name="persistence-local" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <non-jta-data-source>jdbc/sample</non-jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>NONE</shared-cache-mode>
    <properties>
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
      <property name="hibernate.show_sql" value="true"/>
    </properties>
  </persistence-unit>
</persistence>


The main point is when I have the @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) annotation on the runAccount() method I get the following Exception;

Code:
Caused by: org.hibernate.HibernateException: Unable to resume previously suspended transaction
        at org.hibernate.engine.transaction.Isolater$JtaDelegate.delegateWork(Isolater.java:147)
        at org.hibernate.engine.transaction.Isolater.doIsolatedWork(Isolater.java:67)
        at org.hibernate.engine.TransactionHelper.doWorkInNewTransaction(TransactionHelper.java:74)
        at org.hibernate.id.MultipleHiLoPerTableGenerator$1.getNextValue(MultipleHiLoPerTableGenerator.java:216)
......


However, if I remove the @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) annotation (which defaults to TransactionAttributeType.REQUIRED) the method works as expected.

My problems is I don't understand why adding @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) annotation would cause the exception as I was under the impression that a Resource-Local Entity Manager does not use JTA or container managed transactions and therefore if a container managed transaction was not present it shouldn't matter. What also adds to my confusion is in the stack trace I see a reference to a org.hibernate.engine.transaction.Isolater$JtaDelegate.delegateWork(Isolater.java:147) class which reinforces my belief that JTA is still involved in the Resource-Local transaction.

I would be very appreciative of your help and comments and let me know if I have missed something elementary here.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Unable to resume previously suspended transaction error
PostPosted: Wed Jul 07, 2010 1:07 pm 
Newbie

Joined: Wed Jul 07, 2010 12:59 pm
Posts: 1
Have you found a solution to this problem because I'm currently having the same problem. If so, can you provide it please. Thanks in advance.


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.