3 Replies Latest reply on Feb 14, 2006 3:03 AM by f f

    Could not dereference object

    f f Newbie

      Hello,

      I am using Jboss 4.0 3 SP1 with Java SDK 1.5.
      I would simply like to use a datasource (mysql) from a servlet but I get a
      "Could not dereference object exception" when doing :

      Context initCtx = new InitialContext();
      Context envCtx = (Context)initCtx.lookup("java:comp/env");
      DataSource ds = (DataSource)envCtx.lookup("joueurDB");

      Here is my web.xml:

      <resource-ref>
      <res-ref-name>joueurDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      Here is my jboss-web.xml:

      <jboss-web>
      <resource-ref>
      <res-ref-name>joueurDB</res-ref-name>
      <jndi-name>joueurDB</jndi-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      </jboss-web>

      Here is my mysql-ds.xml: (relevant extract)


      <local-tx-datasource>
      <jndi-name>joueurDB</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>

      Here is the JNDI binding log message at server start-up?
      ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=joueurB' to JNDI name 'java:joueurDB'

      What is wrong please? THank you very much in advance for help.