2 Replies Latest reply on Jan 15, 2007 8:03 PM by Néstor Arias

    Can't get JCA datasource using JNDI

    Néstor Arias Newbie

      Actually I'm deploying a website for JBoss. Mi commitment is make this site to work with this databases:


      My fellow and me wrote the access to the database in a simple class (this project has no entity-beans). Servlets and a java application need access to database. Our current database is mysql.

      Finding out a way to configure access to database, I found that using JCA its possible to bind connections to databases using files with the name in the format *ds.xml.
      What I did is to work with a file I called DB-ds.xml (according JCA standard) and wrote an initial mysql configuration. Below is the content of this file:

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- WEBCOMJAFL. Archivo de conexión a la base de datos. -->
       <!-- Datasource config for MySQL using 3.0.9 available from:

      Data in this file is fine (user=webcomjafl, no password)

      After copying this file into server\default\deploy directory of JBoss, I got this message:
      15:59:25,727 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca
      :service=DataSourceBinding,name=comp/env/jdbc/WCJFDB' to JNDI name 'java:comp/env/jdbc/WCJFDB'

      What means that binding was successful.

      I've tried calling this resource (comp/env/jdbc/WCJFDB) from a java-test application, but I had an error message:

      javax.naming.NameNotFoundException: comp not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:392)
       at devenet.com.workflow.DBConnectionTest.main(DBConnectionTest.java:38)

      This is my source code:
      public static void main(String[] args) {
       try {
       InitialContext ctx = new InitialContext();
       Object connection = ctx.lookup("java:comp/env/jdbc/WCJFDB");
       } catch (Exception e) {
       // TODO Auto-generated catch block


      This is my jndi.properties file:
      ### JBossNS properties

      I've installed JBoss version 4.0.5, with all components (full), with jmx interfaces no secured (jmx-console.war, web-console.war, jmx-invoker-service, http invoker).

      I'll be thankful for any help.

      Néstor Arias