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 6719753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:07:49+00:00 2026-05-26T09:07:49+00:00

My project is a WAR project generated with seam-gen. It contains a RESTEasy web

  • 0

My project is a WAR project generated with seam-gen. It contains a RESTEasy web service class like this (simplified, only the relevant parts):

@Scope(ScopeType.APPLICATION)
public abstract class RestService {

    @In
    protected EntityManager entityManager;

    @GET
    @POST
    @Produces("application/json")
    public Object proxy() {
        // invokes various subclass methods
        // based on request parameters
        // and returns the result
    }
    // further method and logic
}

And:

@Path("/my")
@Name("myRestService")
public class MyRestService extends RestService {

    public Object login(/*...*/) {
        User user = getUser(email);

        // ...

        Token token = user.getToken();
        if (token != null) {
            entityManager.remove(token);
        }
        token = new Token();
        entityManager.persist(token);
        user.setToken(token);
        user.setLastlogin(new Date());
        entityManager.persist(user);

        // ...
    }

    private User getUser(String email) {
        try {
            return (User) entityManager
                    .createQuery("FROM User WHERE UPPER(email) = UPPER(:email)")
                    .setParameter("email", email)
                    .getSingleResult();
        } catch (NoResultException e) {
            return null;
        }
    }
}

If i invoke the login method through a web browser, it finds the correct user (based on the get params), instantiates a Token for it (i can see at the STDOUT of Hibernate asking the databse for the next sequence), but the persist() method does not save the Token to the database, neither the modifications of the User object (token id, last login date).

I have googled this for two days now, here’s what i could figure out:

  • my project uses SEAM managed transactions (components.xml):

    <persistence:managed-persistence-context name="entityManager" auto-create="true"
                       persistence-unit-jndi-name="java:/MyEntityManagerFactory"/>
    
  • my project uses JTA for transaction handling (persistence.xml):

    <persistence-unit name="MyProject" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider> ...
    
  • the EntityManager.persist() does NOT commit changes to the database, just queues changes to the current transaction (?)

  • the SEAM managed Transactions are tied to conversations by default

I tried to use .flush(), an exception was thrown saying that there is no transaction in progress.

I tried to use .joinTransaction() and .getTransaction().begin(), another exception was thrown saying that a JTA EntityManager can not access transactions.

Also tried to use different scope types on the class, or use the @Transactional annotation on my login() method, no luck.

Also tried to inject the EntityManager with the @PersistenceContext annotation, this resulted in an exception saying @PersistenceContext can only be used with session beans.

Also tried to mark my class as @Stateless, this resulted that i could not reach my service (404).

How should i persist my Entities within a RESTEasy service with EntityManager?

System specs:

  • JBoss 5.1.0 GA
  • SEAM 2.2.1 Final
  • Postgres 8.3

Please note that i’m totally new and inexperienced with JavaEE/JBoss/SEAM.

Any comment would be useful! Thanks.

  • 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-05-26T09:07:49+00:00Added an answer on May 26, 2026 at 9:07 am

    The transactional annotation is important on the login method. This will ensure that the transaction interceptor is creating a transaction if neccessary. (if there is no transaction yet). The easiest way to find out if the interceptor is applied would be to debug into the login method and check the stack. I’m not sure how the class is called but i will update this post as soon as i’m at work to check it out.
    If this interceptor is not there it means that you are not using seam transactions. The extract of your components.xml is not showing that you do so.

    Martin

    Updated:
    So here’s the stacktrace. Take a look at the TransactionInterceptor if you do not have this in your stack you have no transaction management.

    Daemon Thread [http-18081-1] (Suspended (breakpoint at line 170 in QueryHome))  
        QueryHome.getCandidatesCount() line: 170    
        NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
        NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39  
        DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25  
        Method.invoke(Object, Object...) line: 597  
        Reflections.invoke(Method, Object, Object...) line: 22  
        RootInvocationContext.proceed() line: 32    
        SeamInvocationContext.proceed() line: 56    
        RollbackInterceptor.aroundInvoke(InvocationContext) line: 28    
        SeamInvocationContext.proceed() line: 68    
        BijectionInterceptor.aroundInvoke(InvocationContext) line: 77   
        SeamInvocationContext.proceed() line: 68    
        ConversationInterceptor.aroundInvoke(InvocationContext) line: 65    
        SeamInvocationContext.proceed() line: 68    
        TransactionInterceptor$1.work() line: 97    
        TransactionInterceptor$1(Work<T>).workInTransaction() line: 61  
        TransactionInterceptor.aroundInvoke(InvocationContext) line: 91 
        SeamInvocationContext.proceed() line: 68    
        MethodContextInterceptor.aroundInvoke(InvocationContext) line: 44   
        SeamInvocationContext.proceed() line: 68    
        JavaBeanInterceptor(RootInterceptor).invoke(InvocationContext, EventType) line: 107 
        JavaBeanInterceptor.interceptInvocation(Method, Object[]) line: 185 
        JavaBeanInterceptor.invoke(Object, Method, Method, Object[]) line: 103  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to deploy GWT project to Web-Sphere? I have assemble an .war file, it
a war packaged for a tomcat webapp contains WEB-INF/classes and WEB-INF/lib/*.jar which of them
I'm writing an Ant script to package a project into a WAR file. The
Suppose I have a war and jar projects defined in maven. The Jar project
I currently have a project built with maven-archetype-webapp artifact. The default packaging for this
I have created a web application using Jersey and Dynamic Web Project of Eclipse.
I create an Enterprise Application CustomerApp that also generated two projects CustomerApp-ejb and CustomerApp-war
I'm using maven2 with eclipse for an ear project with multiple war, ejb and
I have the following project layout: WAR Project A Upstream Projects Dependency B Dependency
I have a maven project where I am building a war file, but I

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.