6 Replies Latest reply on Jan 6, 2010 6:57 AM by nick wolf

    Problem with JNDI Datasource on JBOSS 5.1

    nick wolf Newbie
      Hello All,

      can somebody help me with datasource configuration?

      I am using JBOSS 5.1 ,Spring 2.5

      i have the spring configuration file defined as

      <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
      <property name="environment">   
      <props>     
      <prop key="java.naming.factory.initial">org.jnp.interfac  es.NamingContextFactory</prop>
      <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
      <prop key="java.naming.factory.url.pkgs">org.jboss.namingrg.jnp.interfaces</prop>
      <prop key="jnp.disableDiscovery">true</prop>

      </props>
      </property>
      </bean>
      <bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryB  ean">
      <property name="jndiName">
      <value>java:mySource</value>
      </property>
      <property name="resourceRef">
      <value>false</value>
      </property>
      </bean>

      when i tried this i am getting NameNotFound exception...but when i tried to lookup the same using java code it works!!

      i am not sure why spring not able catch hold of this JNDI name...i have given enough trials from internet but it did not workout..

      Thanks,
      kishore
        • 1. Re: Problem with JNDI Datasource on JBOSS 5.1
          Carlo de Wolf Master

          java: signifies a VM name space. Are you running that code within the same VM?

          If not, change the JNDI name to mySource, that should make it globally available.

          • 2. Re: Problem with JNDI Datasource on JBOSS 5.1
            nick wolf Newbie

            Hi,

             

            All i just deployed one simple web application with spring capabilities..

             

            When i call the JNDI name using simple JSP page with scriptlet i am able to get the connection object but when i give the same JNDI name to spring context it is not able to find the NAME in JNDI Tree...i belive spring does not run in a seperate VM?

             

             

            For the refernce i am providing datasource configuration..

             


            <datasources>
              <local-tx-datasource>
                <jndi-name>mysource</jndi-name>
                <connection-url>jdbc:jtds:sqlserver://server:1433/db;tds=8.0;lastupdatecount=true</connection-url>
                <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
                <user-name>sa</user-name>
                <password>password</password>
               <!--
                    sql to call on an existing pooled connection when it is obtained from pool
                -->
                <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>   
              </local-tx-datasource>
            </datasources>

             

            And the server log says..

             

            17:10:23,998 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=mysource' to JNDI name 'java:mysource'

             

            Thanks

            • 3. Re: Problem with JNDI Datasource on JBOSS 5.1
              nick wolf Newbie
              Hi

              i found the problem myself...when i include the hibernate related libraries with my deployed application none of the JNDI references working...when i remove them JNDI references working correctly..
              does anybody experiences this..? any solution i need hibernate libraries to make spring DAO's work? How to resolve this situation?

              This is just wiered behaviour from JBOSS 5.1.0 GA??

              Thanks,
              • 4. Re: Problem with JNDI Datasource on JBOSS 5.1
                nick wolf Newbie

                Guys..

                 

                jboss-archive-browsing.jar from hibernate causing the problem to spring while identifying JNDI datasource...

                 

                Looks like the version i am using is not compatible with JBOSS 5.1.0???

                 

                Anyideas wht this library is used for?

                 

                Thanks,

                • 5. Re: Problem with JNDI Datasource on JBOSS 5.1
                  jaikiran pai Master

                  Which version of Hibernate do you use? And please post the entire exception stacktrace.

                  • 6. Re: Problem with JNDI Datasource on JBOSS 5.1
                    nick wolf Newbie

                    i am using 3.2 version but  JBOSS 5.1.0 has 3.4 in common\lib...removing the old libraries solved the problem...

                     

                    it seems jboss-archiving-browsing.jar has no use in 3.4 version..

                     

                    Thanks,

                    Nick