EntityManager injection not working inside fact models deployed as jar inside deployed application in BRMS 6
Issue
- As per this specific requirement a
Droolsproject defines a bunch of rules inBusiness Central. The fact models, where these rules act on are uploaded in form of a jar (say,abc.jar) to define those facts and uploaded in themaven repositoryofBusiness Central. These rules are executed from a Web service application that fetches the rules fromBusiness Centralthrough kjars present insideMaven repositoryofBusiness Centraland runs them locally i.e. in the Web service application. The fact model jar (abc.jar) is also packaged inside the Web service application to help the execution of the rules. The Web service has its ownEntityManagerwhich the underlying EAP 6 container injects just fine. According to the requirement the fact model jar (abc.jar) also needs access to the database due to which it needs access to theEntityManagerinside it's code.
e.g.
...
public class SimpleFact
{
@PersistenceContext(unitName="FactEntity")
static EntityManager em;
...
public static List<String> getData() {
List testData = new ArrayList();
...
TypedQuery typeQuery = em.createQuery(selecteQuery, FactResult.class);
...
return testData;
}
...
- The problem is that
EAP 6container is not injecting theEntityManagerinto the fact models as like it does for the Web service application code. Why is that? Is that because the fact model is only aJarand not aWARorEAR?
Environment
- Red Hat JBoss BRMS (BRMS)
- 6.0.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
