"Connection is not associated with a managed connection" when Connection is reused in JBoss EAP

Solution Verified - Updated -

Issue

  • We have a @Stateful EJB which caches Connection and PreparedStatement objects in a field. When they are re-used, we get an exception

    java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.WrappedConnection@19ce161
      at org.jboss.resource.adapter.jdbc.WrappedConnection.lock(WrappedConnection.java:83)
      at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:235)
      ...
    
  • Encountering the following error when attempting an operation on a connection in EAP 6

    java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@174b8c5
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 4
    • 5
    • 6
    • 7

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.