Search code examples
jakarta-eejpawildfly-8

WildFly deploy: Unable to create EntityManager with SynchronizationType


I am trying to migrate a GlassFish 4.0 webapp to deploy on WildFly 8.1.0 FINAL. The app deploys correctly, but after sendind GET request (e.g. typing localhost:8080/meanful/), strange error occurs:

2:57:15,493 ERROR [org.jboss.as.ejb3.invocation] (default task-4) JBAS014134: EJB Invocation failed on component SystemDaoImpl for method public abstract boolean com.meanful.service.system.SystemDao.contains(java.lang.String): javax.ejb.EJBException: java.lang.IllegalStateException: Unable to create EntityManager with SynchronizationType because PersistenceUnit is configured with resource-local transactions.

My persistence.xml looks like this and is fully functional with the same version of EclipseLink on my GlassFish 4 server.

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence     http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="mysqlPersistenceUnit" transaction-type="JTA">
      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
      <jta-data-source>java:/jdbc/mySQL</jta-data-source>
     <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>NONE</shared-cache-mode>
    <properties>
        </properties>
  </persistence-unit>
</persistence>

The implementation class itself looks like this:

@Stateless
public class SystemDaoImpl implements SystemDao {

@PersistenceContext private EntityManager entityManager;

@Override
public boolean contains(String infoKey) {
    return entityManager.find(SystemInfo.class, infoKey) != null;

    }

Entity manager is injected. The error is thrown when the program reaches the inside of contains() method (there is only one line).

The connection is set properly, connection test shows everything is OK. JTA is enabled enter image description here


Solution

  • Please, check for line:

    <resource-root path="jipijapa-eclipselink-1.0.1.Final.jar"/>

    in your modules/system/layers/base/org/eclipse/persistence/main/module.xml <resource> element.

    jipijapa-eclipselink-1.0.1.Final.jar:

    This library is a collection of utility classes to aid the integration of EclipseLink into JBossAS7

    There should be two lines (an integration and eclipselink library) according to:

    JPA Reference Guide - Using EclipseLink