2

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

  • Just guessing, are you using a local-tx-datasource? If yes, maybe you need to use an XA-datasource: `com.mysql.jdbc.jdbc2.optional.MysqlXADataSource` – Torsten Römer Jun 27 '14 at 12:15
  • I've added a screenshot with my Datasource settings. Everything looks fine to me. –  Jun 27 '14 at 12:52
  • Yes looks all fine to me too. – Torsten Römer Jun 27 '14 at 13:02
  • I've tried creating non-xa datasource with just com.mysql.jdbc2.optional.MysqlDataSource - to no avail. However in both cases, ping (test connection) works. –  Jun 27 '14 at 13:07
  • 1
    It has probably nothing to do with the datasource. Another guess: You write you are using EclipseLink while WildFly uses Hibernate. Could it be that you have an EclipseLink jar in your deployment that you maybe just need to remove? – Torsten Römer Jun 27 '14 at 13:26
  • I deployed EclipseLink into modules/system/... and there is EclipseLink defined as a provider in persistence.xml. I tried to run on Hibernate, but the whole application is JEE 7 - JPA specific, which means I am getting errors while using Hibernate. –  Jun 27 '14 at 15:52
  • WildFly 8 is JEE 7 including JPA provided by Hibernate so I suppose your JEE 7 app should ideally just work and it should not be necessary to use EclipseLink. – Torsten Römer Jun 27 '14 at 16:08
  • Your advice to switch to Hibernate works. Thank you. –  Jun 27 '14 at 17:28
  • You are welcome, good it works now! – Torsten Römer Jun 27 '14 at 18:40

2 Answers2

2

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

sereja
  • 1,356
  • 1
  • 8
  • 6
1

This Issue is EclipseLink related. EclipseLink 2.5.1. was defined as a provider in persistence.xml. After removing this declaration and letting Hibenate bundled in WildFly do it's work, everything works.

I still haven't found out why this strange error occurs. It looks like EclipseLink thinks transaction management is RESOURCE_LOCAL.