3 Replies Latest reply on Nov 18, 2011 7:17 AM by xjohnx

    Datasource specification in web.xml

    xjohnx

      Hi,

      I have my project application which has been connecting to one simple datasource(which was defined in jbos-web.xml). Now I need to build form my application two *.war files and each of them will use different datasource. Since Im using ant, I can change in my build.xml file destination of web.xml file. So I have two web.xml files with different datasource deffinitions.

      The problem is, that my solition is not working. After triing to reach my appplication i get error:

       

      javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc not bound]

       

      web.xml

      <resource-ref> 
       <res-ref-name>DataSource</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <mapped-name>DataSource</mapped-name>
      </resource-ref>
      

       

      adpartner-ds.xml

      <local-tx-datasource>
          <jndi-name>DataSource</jndi-name>     
      .....
      

       

      java code:

      InitialContext ctx = null;
       try {
       ctx = new InitialContext();
      
       dataSource = (DataSource) ctx.lookup("java:comp/env/DataSource");
       LOG.info("lookup na datasource");
       } catch (NamingException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
       this.daoFactory = new DaoFactory(this.dataSource);
      
      

       

      I've tried to search solution on web but without any success.

      Thanks for any help.