5 Replies Latest reply on Mar 16, 2009 3:13 AM by jaikiran pai

    problems with jdbc jndi lookups

    dave potts Newbie

      I have an exist application deployed under jboss 4.2.3, I have used jboss.xml to map local jndi refferences into the global jndi pool and have no problems.

      But upgrading to jboss AS 5.0 seems to have caused problems

      My jndi refs were listed under the name name of

      java:comp/env/jdbc/foobar

      But the desired syntax now seems to be

      comp/env/jdbc/foobar

      What ever I set jboss.xml seems to get ignored.

      I can use the jmox console to look up my jndi references and see them declared as comp/env/jdbc/foobar in the global jndi pool.

      If I <use-java-context>true</use-java-context> in my postgres-ds.xml, then I can see java:comp/env/jdbc/foobar being mapped in the server output log, but it does'nt appear in the global jndi pool.

      Has something changed in jboss 4.23 and 5.0 ? to do with the mapping of jndi resources.

      Is there a guide anywhere on the net on the correct way of doing this type of thing.

      D.

        • 1. Re: problems with jdbc jndi lookups
          jaikiran pai Master

          Post your datasource file (which used to work for 4.x). The java:comp/env namespace is not something that is configured through the datasource file. It is configured to web.xml and jboss-web.xml for the war component.

          • 2. Re: problems with jdbc jndi lookups
            dave potts Newbie

            From my jboss-web.xml

            <resource-ref>
            <res-ref-name>jdbc/castleDB</res-ref-name>
            <jndi-name>java:/jdbc/castleDB</jndi-name>
            </resource-ref>

            From my web.xml

            <resource-ref >
            <res-ref-name>jdbc/castleDB</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            </resource-ref>
            Any suggestions as to where I am going wrong on jboss 5.0?

            • 3. Re: problems with jdbc jndi lookups
              jaikiran pai Master

              You haven't posted the datasource file (-ds.xml). Please post that.

              While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.

              • 4. Re: problems with jdbc jndi lookups
                dave potts Newbie

                my postgres-ds.xml file for jboss 4.2 and 5.0 is

                <?xml version="1.0" encoding="UTF-8"?>
                
                <datasources>
                 <local-tx-datasource>
                
                 <jndi-name>jdbc/castleDB</jndi-name>
                 <connection-url>jdbc:postgresql://localhost:5434/castle</connection-url>
                 <driver-class>org.postgresql.Driver</driver-class>
                 <user-name>dp42</user-name>
                 <password></password>
                 <!-- sql to call when connection is created. Can be anything, select 1 is valid for PostgreSQL
                 <new-connection-sql>select 1</new-connection-sql>
                 -->
                
                 <!-- sql to call on an existing pooled connection when it is obtained from pool. Can be anything, select 1 is valid for PostgreSQL
                 <check-valid-connection-sql>select 1</check-valid-connection-sql>
                 -->
                
                 <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
                 <metadata>
                 <type-mapping>PostgreSQL 8.0</type-mapping>
                 </metadata>
                
                 </local-tx-datasource>
                
                 <local-tx-datasource>
                 <jndi-name>PostgresDS</jndi-name>
                 <connection-url>jdbc:postgresql://localhost:5434/postgresStock</connection-url>
                 <driver-class>org.postgresql.Driver</driver-class>
                 <user-name>dp42</user-name>
                 <password>haggis42</password>
                 <!-- sql to call when connection is created. Can be anything, select 1 is valid for PostgreSQL
                 <new-connection-sql>select 1</new-connection-sql>
                 -->
                
                 <!-- sql to call on an existing pooled connection when it is obtained from pool. Can be anything, select 1 is valid for PostgreSQL
                 <check-valid-connection-sql>select 1</check-valid-connection-sql>
                 -->
                
                 <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
                 <metadata>
                 <type-mapping>PostgreSQL 8.0</type-mapping>
                 </metadata>
                 </local-tx-datasource>
                </datasources>
                


                #I am not aware of any changes between version 4.2 and 5.0.


                • 5. Re: problems with jdbc jndi lookups
                  jaikiran pai Master

                  Based on these configuration files, the datasource should be available in the ENC of the war component under java:comp/env/jdbc/castleDB. Are you able to use this to lookup the datasource? Also where and when are you using this JNDI name to lookup the datasource? Can you post that relevant code. Finally please post the entire jmx-console JNDI tree output as explained here http://www.jboss.org/community/docs/DOC-9584