Call Hazelcast Map to use Transaction from EJB client (Web Application) not work

Skip to first unread message

Cidy Long

Aug 26, 2021, 12:14:53 AM8/26/21
to Payara Forum

Payara 5.2021.5 community edit, 
OS: Centos 8

I'm trying to access Hazelcast map from Web Application.

1. Entity bean JPA persistence.xml as:
<persistence-unit name="PG12_OZSSC_JTAPU" transaction-type="JTA">
2. Hazelcast map MapStore coded with:
private static final String JTA_PU_NAME = "PG12_OZSSC_JTAPU";

   @PersistenceUnit(unitName = JTA_PU_NAME)
   private EntityManagerFactory emf;
   @PersistenceContext(unitName = JTA_PU_NAME)
   private EntityManager em;
public synchronized void store(String s, Address address) {
protected void storeEntityToDB(Address entity){
       Address exist = em.find(Address.class,entity.getAddressId());
       if (exist != null){
           if (!entity.equals(exist)){
3. map configure in hazelcast-config.xml as
<map name="address">
       <map-store enabled="true" initial-mode="EAGER">
           <!-- <write-batch-size>100</write-batch-size> -->
4. map access by load(),loadAll() etc. over hazelcast instance properly

5. Build a EJB module with remote interface, and implements the remote
- Remote interface as:
public interface AddressRemote {
   void save(Address address);
   void remove(Address address);
- Remote impleements as:
@Singleton(name = "addressEJB",mappedName = "EJBModule-EJB-addressEJB")
public class AddressRemoteImpl implements AddressRemote, Serializable {
   public void init(){
       if(hzInstance != null){
           addressMap = hzInstance.getMap(ADDRESS_MAP_NAME);
   public void save(Address address) {
       if(addressMap != null){
           try {
               throw new NotFoundException("Address Map not fund from Address EJB implementation.");
           } catch (NotFoundException e) {
5. When I tried to call the EJB services from Web Applicaiton
JSF web controller as:
@Named(value = "addressHostWebController")
public class AddressHostWebController implements Serializable {
public String saveEntity(){;
       return LIST_ADDRESS;
when call controller's save()function to save an address to map
(As hazelcast-config.xml defined, the once map entry was updated, Hazelcast will write through to database straight way)
But, unfortunately, javax.persistence.TransactionRequiredException: throws as:
[2021-08-26T11:18:18.051+1000] [Payara 5.2021.5] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=100 _ThreadName=http-thread-pool::http-listener-1(3)] [timeMillis: 1629940698051] [levelValue: 900] [[
 StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
Exception Description: No externally managed transaction is currently active for this thread
at org.eclipse.persistence.internal.jpa.transaction.JTATransactionWrapper.throwCheckTransactionFailedException(
Seems, save() function caller (web application) not enabled to use JPA's entityManager's transactions? or I had some persistence.xml configure missed? or some thing else?
Reply all
Reply to author
0 new messages