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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:09:48+00:00 2026-06-14T13:09:48+00:00

Environment Application server: JBoss AS7 (7.1.1 Final) JPA implementation: EclipseLink (2.4.1) OS: Windows 7

  • 0

Environment

Application server: JBoss AS7 (7.1.1 Final)

JPA implementation: EclipseLink (2.4.1)

OS: Windows 7 DB: PostgreSQL 8.4

Update 2, solved

The problem was that i instantiated the AccountService class instead of injecting it using @EJB. After fixing that EntityManager was inected correctly in the service and a transaction was available when doing em.persist(account);

Update

I made a minimal project that shows my problems. Posted to Github:

https://github.com/gotling/jboss-eclipselink-problem

I have two problems that are probably related and due to me not understanding the use of EJB’s correct.

  1. I can not get EnityManager to be injected in AccountService.java in persistance JAR, resulting in NullPointerException.

  2. If sending EntityManager in constructor to AccountService no tranasaction is found when doing em.persist.

Project structure

EJB

  • lib/persistanceunit.jar

  • web-service.war

Problem

I’m trying to get JBoss to manage transactions in my Java EE service. Problem is that EclipseLink does not seem to pick up the transaction managed by JBoss when trying to persist an entity.

I have followed the guide https://community.jboss.org/wiki/HowToUseEclipseLinkWithAS7 (Alternative 1 and Alternative 2 Step 4) on how to configure JBoss with EclipseLink.

Setup

WAR

Entity manager is injected like this in web-service.war:

@WebService(....)
public class NotificationConsumerImpl implements NotificationConsumer {
    @PersistenceContext(unitName="foo")
    EntityManager em;

    public void notify(Notify notify) {
        AccountService accountService = new AccountService(em);
        accountService.create(notify);
    }
}

There is actually a controller class between the class above and the service class, where transformation of the Account object is done, removed it to shorten code.

Persistance Unit

Entity is created like this

AccountService.java in persistanceunit.jar

@Stateless
public class AccountService {
    private EntityManager em;

    public AccountService(EntityManager em) {
        this.em = em;
    }

    public void create(Account account) {
        em.persist(account);
    }
}

Stack trace

When calling a WS that should persist the Account entity I get an exception on em.persist(account);

...
Caused by: javax.persistence.TransactionRequiredException: JBAS011469: Transaction is required to perform this operation (either use a transaction or extended persistence context)
at org.jboss.as.jpa.container.AbstractEntityManager.transactionIsRequired(AbstractEntityManager.java:692) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.jpa.container.AbstractEntityManager.persist(AbstractEntityManager.java:562) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at se.magos.service.AccountService.create(AccountService.java:50) [persistenceunit-0.0.1-SNAPSHOT.jar:]

Questions

  1. I’ve enabled Trace logging. Should not id.au.ringerc.as7.eclipselinkpersistence be visible in the log?

  2. Is it somehow possible to get the EntityManager injected inside the service class inside the persistanceunit.jar?

  3. In which JBoss / EclipseLink version should this wor out of the box?

  • 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-14T13:09:49+00:00Added an answer on June 14, 2026 at 1:09 pm

    The problem was that AccountService class was instantiated instead of injected using @EJB annotation. After fixing that EntityManager was injected correctly in the service and a transaction was available when doing em.persist(account);

    Before

    @WebService(....)
    public class NotificationConsumerImpl implements NotificationConsumer {
        @PersistenceContext(unitName="foo")
        EntityManager em;
    
        public void notify(Notify notify) {
            AccountService accountService = new AccountService(em);
            accountService.create(notify);
        }
    }
    

    After

    @WebService(....)
    public class NotificationConsumerImpl implements NotificationConsumer {
        @PersistenceContext(unitName="foo")
        EntityManager em;
    
        @EJB
        AccountService accountService;
    
        public void notify(Notify notify) {
            accountService.create(notify);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Weblogic application server and Apache web server in my J2EE environment and
Is it true : Cocoa is an application environment that consist of several Frameworks
I'm trying to set up a test environment for our application that uses X.509
I have a web application that works in our stage/test environment fine but once
I am writing a netty client and server application that will write JVM GC
I have a network server that was implemented using Jboss Netty. It servers the
I am using JBoss 4.2.2.GA app server in a development environment. I have a
I have a server application that has been instrumented using JMX so that it
Environment: Server : Jboss 4.2.3.GA We are using c3p0 0.9.1.2 for connection pooling. Whenever
I'm trying to make Jboss Application Server 7.1.0 run as a service using the

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.