I'm working with jboss wildfly 9. I have a provider deployed as module into the :
wildfly > modules > com > mycompany > myprovider
folder. Then i have a jpa project with DAO pattern writing and reading inside my database. I want to handle the DAO transaction using JTA but in order to make the DAO class visibile to myprovider i need to put the DAO JPA project inside the modules directory too.
Now face the real problem: it seems i cannot use the @PersistenceContext annotation to inject the entity managare into my EntityManager varible:
@PersistenceContext(unitName = "KAS-Mapping")
private EntityManager entityManager;
this is my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<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="KAS-Mapping">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>my.class.persistence.model.MapGroup</class>
<class>my.class.persistence.model.MapUser</class>
<properties>
<property name="javax.persistence.provider" value="org.hibernate.ejb.HibernatePersistence" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="javax.persistence.provider" value="org.hibernate.jpa.HibernatePersistenceProvider"/>
<property name="javax.persistence.transactionType" value="JTA"/>
<property name="javax.persistence.jtaDataSource" value="java:jboss/datasources/MyDS"/>
</properties>
</persistence-unit>
</persistence>
Why i cannot inject the a context into a jar modules? What am i wrong?