Wildfly 24.0.1
Bootable Jar (wildfly-jar-maven-plugin) 5.0.2.Final
Also note, the specific code was working as expected in Thorntail, only with the migration to WildFly Bootable Jar the problem occurred.
The below I’ve tested with various different scenarios(schedule the ManagedScheduledExecutorService from the servlet, from the EJB, from a POJO class that was invoked by the EJB, from a POJO class that was invoked by the servlet) the outcome always the same:
[org.hibernate.jpa.boot.internal.PersistenceXmlParser] (EE-ManagedScheduledExecutorService-TestAppScheduler-Thread-2) HHH000318: Could not find any META-INF/persistence.xml file in the classpath
za.co.absa.esf.exceptions.SystemException: No Persistence provider for EntityManager named XOB_LOCAL_PU: Exception Msg: No Persistence provider for EntityManager named XOB_LOCAL_PU
This happens if you access the specific Persistence Unit for the first time (only) in an EE concurrency Utility.
For example:
Maven project – WAR only
Persistence.xml location: \src\main\resources\META-INF\
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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="primary"> <!-- Defaults to transaction-type="JTA" -->
<jta-data-source>java:jboss/datasources/testJTADS</jta-data-source>
<class>za.co.absa.test.function.dao.jpa.Function</class>
<properties>
<property name="hibernate.default_schema" value="test"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect"/>
</properties>
</persistence-unit>
<persistence-unit name="nonjta" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/testDS</non-jta-data-source>
<class>za.co.absa.test.function.dao.jpa.Function</class>
<properties>
<property name="hibernate.default_schema" value="test"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect"/>
</properties>
</persistence-unit>
</persistence>
Datasource configurations:
# ************************************************************************************************
# PostgreSQL datasource configurations
# ************************************************************************************************
/subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-class-name=org.postgresql.Driver)
data-source add \
--jndi-name=java:jboss/datasources/testJTADS \
--name=testJTADS \
--connection-url=jdbc:postgresql://localhost:5432/testdb \
--driver-name=postgresql \
--security-domain=passw \
--min-pool-size=1 \
--max-pool-size=10 \
--transaction-isolation=TRANSACTION_READ_COMMITTED \
--idle-timeout-minutes=1 \
--blocking-timeout-wait-millis=5000 \
--jta=true \
--prepared-statements-cache-size=10 \
--flush-strategy=EntirePool \
--exception-sorter-class-name=za.co.test.CustomPostgreSQLExceptionSorter
data-source add \
--jndi-name=java:jboss/datasources/testDS \
--name=testDS \
--connection-url=jdbc:postgresql://localhost:5432/testdb \
--driver-name=postgresql \
--security-domain=passw \
--min-pool-size=1 \
--max-pool-size=10 \
--transaction-isolation=TRANSACTION_READ_COMMITTED \
--idle-timeout-minutes=1 \
--blocking-timeout-wait-millis=5000 \
--jta=false \
--prepared-statements-cache-size=10 \
--flush-strategy=EntirePool \
--exception-sorter-class-name=za.co.test.CustomPostgreSQLExceptionSorter
My TestServlet schedules the ManagedExecutorService.
managedScheduledES.schedule(task, trigger);
Trigger – runs every 2 minutes. Task instanciates the DAO and the appropriate method on the DAO is called to add a record.
The exception occurs on the instantiation of the DAO as it is in the constructor of the DAO where the EM gets created.
All other scenarios don’t have the issue. For example, calling the DAO from an EJB or from the Servlet class or from a POJO class.
That is all working as expected. If the PU was loaded for the first time in (for example) the EJB then the ManagedScheduledExecutorService is ok.
It is only when the PU must be loaded for the first time from an EE Concurrency Utility (ManagedScheduledExecutorService or ManagedExecutorService).--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/b46779c9-70bf-48e9-b5d1-56694c9ddc46n%40googlegroups.com.
With regards to this issue, the following:
I had to explicitly add context-service=default for the application specific Managed Executor Service and application specific Managed Scheduled Executor Service
/subsystem=ee/managed-scheduled-executor-service=TestAppScheduler:add(jndi-name=java:jboss/ee/concurrency/scheduler/TestAppScheduler, core-threads=20, context-service=default)
This doesn’t make sense to me as the WildFly documentation states that context-service is an optional attribute.
Thorntail I know assumes defaults for you when not specifying attributes, thus we never defined the context-service.
So what I meant to say is that by explicitly adding context-service=default, solved this issue. Which is still confusing to me as context-service=default should be the default if you do not explicitly specify it.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/b885b801-bd54-4167-9e69-4e3ea00dd7cbn%40googlegroups.com.