[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Datasource injection not working on Web Services ?
dimar1975
do-not-reply at jboss.com
Wed Feb 11 09:26:27 EST 2009
Hi all !
I'm trying to inject a Datasource in a Webservice....
@WebService(name = "CalculatorWS", targetNamespace = "http://webservice_calc/calculator")
| public class CalculatorWS
| {
| @Resource(mappedName="java:/OracleDS")
| DataSource datasource;
|
| @WebMethod
| public Person calculate(Object obj) {
| System.out.println("Datasource is " + datasource; // NULL !!
| // .....
| }
| }
The Datasource injected is null in the method calculate.....
so I have tried to get the datasource with the InitialContext
DataSource ds = (DataSource)new InitialContext().lookup("java:/OracleDS");
|
| Connection conn = null;
| try {
|
| conn = ds.getConnection();
| System.out.println("Connection with initial context" +conn);
| }
and the Connection is correctly retrieved.
Do I miss something to make it work also with injection ???
Thanks a lot
Marco
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4209058#4209058
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4209058
More information about the jboss-user
mailing list