0 Replies Latest reply on Feb 12, 2009 5:29 AM by ermes martino

    Is it possible to inject a Datasource in a JBoss WS ?

    ermes martino Newbie

      Hi all !
      I have posted this question in the persistence forum yesterday, but I had no luck. Meybe this forum is more appropriate: so I'm trying to inject a Datasource in a Webservice....

      @WebService(name = "CalculatorWS", targetNamespace = "http://webservice_calc/calculator")
      public class CalculatorWS
       DataSource datasource;
       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 ???
      The AS I0m using is JBoss 5.0 GA but I have tested also with 4.2 and it doesn't work too. :-(
      Thanks a lot