1 Reply Latest reply on Feb 6, 2007 2:23 PM by Juha Lindfors

    Datasource not correctly bound to JNDI context

    Alexander Schulz Newbie

      Hi,

      I'm porting an application from Orion to JBoss. I'm trying to configure the datasource at the same JNDI-names like in Orion (starting with comp/env/jdbc) but I have no success with that. I'm using JBoss [4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)].

      I configured the folling datasource:

      <local-tx-datasource>
      <jndi-name>comp/env/jdbc/bps</jndi-name>
      <connection-url>jdbc:oracle:thin:@XYZ</connection-url>
      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      ...
      <exception-sorter-class-name>
      org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
      </exception-sorter-class-name>

      <type-mapping>Oracle9i</type-mapping>

      </local-tx-datasource>


      At startup JBoss says:
      Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=comp/env/jdbc/bps' to JNDI name 'java:comp/env/jdbc/bps'

      When I lookup in the context for that JNDI name I receive the default (hsqldb defaultDS) connection.

      If I name the datasource just jdbc/bps everything is working correct. It seems to me that it is not possible to name a datasource beginning with comp/env. Is this correct or a bug?

      Some previous posting describe simular problems. This can be a big problem for people porting existing applications to JBoss.

      Please, can somebody enlight me.

      Tanks in advance.
      Alex

        • 1. Re: Datasource not correctly bound to JNDI context
          Juha Lindfors Master

          You're going the wrong way about it -- the idea is that the beans use the java:comp/env/jdbc/bps lookup name that is mapped to the app server's environment (arbitrary datasource name).

          You don't need to change your datasource configuration or jndi-name, what you want to do is configure jboss.xml for your beans that maps the java:comp/env/jdbc/bps lookup to the datasource JNDI name binding (these are defined in the standard EJB xml as resource reference entries and then mapped in jboss.xml to app server's datasource deployments).

          It's not a bug, it's a case of misunderstanding/abusing the spec provided mechanisms. Introductory guides books on J2EE using JBoss as example deployment environment will give you more details.