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:


  |   <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>
  | 

and injecting into the servlet as follows:


  | @Resource(mappedName="bank")
  | 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.

- Tom


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
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to