[jboss-user] [Tomcat, HTTPD, Servlets & JSP] - @Resource Injection fails in servlet the second time
do-not-reply at jboss.com
Thu Feb 26 12:03:55 EST 2009
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:
anonymous wrote : 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)
This is a test project for training purposes. I am using a mysql datasource thus:
and injecting into the servlet as follows:
| private DataSource dataSource;
Either the datasource is timing out or I have misunderstood the lifecycle of dependency injection into servlets somehow.
A straight lookup of the datasource works, incidentally, on each servlet call:
| Context ctxt = new InitialContext();
| dataSource = (DataSource)(ctxt).lookup("bank");
Clearly I've missed something important here. I've had similar issues injecting EJBs into servlets with JBoss 5 (i.e. works first time then fails subsequently) but I realise there are issues with this in any case.
Any help gratefully appreciated.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4213454#4213454
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4213454
More information about the jboss-user