Reputation: 22027
I wanted to do some scheduled JDBC job within a bean.
And I got.
Internal Exception: java.sql.SQLException: Error in allocating a connection.
Cause: java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource:
cannot add more resources.
Error Code: 0
@LocalBean @Stateless
class MyBean {
public void doJPA() {
}
@Schedule
public void doJDBC() {
}
@PersistentContext
EntityManager entityManager;
@Resource
DataSource dataSource;
}
Did I do anything wrong?
Do I just have to split the bean?
Thank you.
Upvotes: 0
Views: 861
Reputation: 18389
If you use the same DataSource as JPA is using, the server should give you the same connection, so you should not get this error. Are you using a different data source?
You could also get the JDBC Connection from your EntityManager using unwrap()
Upvotes: 1