I am trying to inject a JDBC DataSource into a servlet running on JBoss 5.0.0.GA
The DataSource injection appears to work the first time the servlet is called (after deployment) and I get a Connection successfully.
However, when the servlet is called the second time, I get an error:
16:53:59,687 ERROR [STDERR] org.jboss.util.NestedSQLException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.; - nested throwable: (javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.)
16:53:59,687 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
<local-tx-datasource> <jndi-name>bank</jndi-name> <use-java-context>false</use-java-context> <connection-url>jdbc:mysql://localhost:3306/bank</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>training</user-name> <password>codeclass</password> </local-tx-datasource>
@Resource(mappedName="bank") private DataSource dataSource;
Context ctxt = new InitialContext(); dataSource = (DataSource)(ctxt).lookup("bank");