Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:04:50+00:00 2026-06-14T12:04:50+00:00

Hello everybody i’m looking for some help with the next problem: i have a

  • 0

Hello everybody i’m looking for some help with the next problem:
i have a jpa/stateless ejb’s proyect that works perfectly, it just does simple queries and persist operations, but now i need to execute a set of persist operations, if any of them fails, i must perform a rollback, so i found JTA can do the job but using this piece of source code:

@Stateless
public class ProjectBean implements IProject {

@Resource
javax.transaction.UserTransaction utx;
@PersistenceContext(unitName = "JPADB")
private EntityManager entityManager;
  ...
 //more code

//this is part of a method
try{
utx.begin();
entityManager.joinTransaction();
    for(Project p:projectResultList){
                entityManager.persist(p);
            }
            utx.commit();
        }catch(Exception e){
            e.printStackTrace();
            if(utx != null)
                try {
                    utx.rollback();
                } catch (IllegalStateException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (SecurityException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (SystemException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                //tx.rollback();
        }

simply doesn’t work, and this is how the persistence.xml looks like:

<persistence-unit name="JPADB">
<jta-data-source>java:jboss/datasources/OracleBic</jta-data-source>
    <properties>
        <property name="hibernate.show_sql" value ="true" />
        <property name="hibernate.dialect"  value="org.hibernate.dialect.Oracle10gDialect" />
    </properties>
</persistence-unit>

really hope anyone can give me a tip or advice, i’m a newbie with jpa/jta concepts and i tried lots of codes i found in the web but i always obtain different errors (Wrong tx on thread: expected TransactionImple usertransaction begin,Cannot use an EntityTransaction while using JTA). thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:04:51+00:00Added an answer on June 14, 2026 at 12:04 pm

    Did you instruct your AS that you are going to handle transactions manually with
    @TransactionManagement(TransactionManagementType.BEAN) on method level? I do not see the annotation on class level. Probably you have it on method level, but your code snipped is insufficient to make any guess.
    Otherwise all transactions are Container managed and your code is not going to work. So you have to either put
    @TransactionManagement(TransactionManagementType.BEAN)
    on either a method or class level depends on requirements or you may want to allow your container to manage transactions for you and than you have to make changes that @remigio suggested to you.
    It seems that the second approach is better in your case

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everybody I have a problem with exception. The following code block do this
Hello everybody :D I would like to ask for your help on this problem.
Hello everybody I have some certs in SQL 2008 but am by no means
Hello everybody, I have this problem (title of the post). Failure/Error: get :create, :user
Hello everybody and thanks for interest some time ago i have started to use
Hello everybody, I have a small code in PHP that I would like to
Hello everybody i have C++ tStringGrid I want to get string from specific cell
hello everybody i have a listbox within which is a datatemplate.Inside it is checkbox,textbox,label...Wat
Hello everybody! I have a SQL (see above) and i would like to know
Hello and thank you for taking the time to help me solve my problem.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.