0 Replies Latest reply on Oct 1, 2002 7:32 AM by Sergei Batiuk

    "Could not dereference object" while looking up a datasource

    Sergei Batiuk Newbie

      Hello,

      My environment is:

      JBoss-3.0.2+Tomcat-4.0.4 (integrated)
      JDK 1.4
      Win2000

      I am trying to access a datasource from a web app, using this code:

      Context ctx = new InitialContext();
      DataSource ds = ( DataSource )ctx.lookup( "java:comp/env/jdbc/DeptFuncDS" );

      However, I get the

      javax.naming.NamingException: Could not dereference object [Root exception is java.lang.NullPointerException].

      What is the problem? If there is an error, what is a correct way to lookup a data source from a web-app?

      My jboss-web.xml:

      <?xml version="1.0"?>
      <jboss-web>
      <resource-ref>
      <resource-ref-name>jdbc/DeptFuncDS</resource-ref-name>
      <jndi-name>java:/OkeanTestDS</jndi-name>
      </resource-ref>
      </jboss-web>

      Note: java:/OkeanTestDS works correctly with CMP EJBs.


      Snip from the web.xml:
      <?xml version="1.0"?>
      <web-app>
      ..
      <resource-ref>
      <res-ref-name>jdbc/DeptFuncDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Sharable</res-sharing-scope>
      </resource-ref>
      ..
      </web-app>