[
https://issues.jboss.org/browse/WFLY-3137?page=com.atlassian.jira.plugin....
]
Stuart Douglas commented on WFLY-3137:
--------------------------------------
The entity manager is a container managed transaction scoped entity manager, calling close
will result in an error.
All you really need is:
@PersistenceContext(unitName = mydatasource)
@Produces
@MyEm
private EntityManager em;
The EM is automatically closed at transaction commit/rollback time.
logging errors in destroying a requestscoped entitymanager
----------------------------------------------------------
Key: WFLY-3137
URL:
https://issues.jboss.org/browse/WFLY-3137
Project: WildFly
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: CDI / Weld
Affects Versions: 8.0.0.Final
Environment: window 7 64bits, javaee 1.7
Reporter: Richard Yang
Assignee: Stuart Douglas
I have a simple producer for a requestscoped entitymanager:
@PersistenceContext(unitName = mydatasource)
private EntityManager em;
@Produces
@myEM
@RequestScoped
protected EntityManager createEntityManager() {
return em;
}
protected void closeEntityManager(
@Disposes @myEM EntityManager entityManager) {
if (entityManager.isOpen()) {
entityManager.close();
}
}
I inject this to applicationScoped bean. In the log, I see for each close of
entityManager, wildfly logs an error:
WELD-000019: Error destroying an instance
org.jboss.as.jpa.container.TransactionScopedEntityManager@7c213180 of Producer Method
[EntityManager] with qualifiers [@myEM @Any] declared as [[BackedAnnotatedMethod]
@Produces @myEM @RequestScoped protected createEntityManager()]
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira