Results 1 to 4 of 4

Thread: Name jdbc is not bound in this Context

  1. #1
    Join Date
    Nov 2011
    Posts
    18

    Question Name jdbc is not bound in this Context

    Hi,
    I am getting "javax.naming.NameNotFoundException: Name jdbc is not bound in this Context" error while configuring datasource using jndi and lookup in spring app-context.

    Following things I did:

    After referring - http://tomcat.apache.org/tomcat-6.0-...les-howto.html
    In C:\dev\apache-tomcat-6.0.33\conf\context.xml
    Code:
    <Resource name="jdbc/mtk_poa_db" auth="Container" type="javax.sql.DataSource"
                   maxActive="100" maxIdle="30" maxWait="10000"
                   username="root" password="admin" driverClassName="org.apache.commons.dbcp.BasicDataSource"
                   url="jdbc:mysql://localhost:3306/mtk_poa"/>
    In application-context:
    Code:
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
          <property name="jndiName" value="java:comp/env/jdbc/mtk_poa_db"/>    
          <property name="resourceRef" value="true" /> 
    </bean>
    But it does not work.
    Havenot done any entry in web.xml and server.xml.

    Please suggest.

  2. #2
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    Have you tried just using

    "jdbc/mtk_poa_db"

    like

    Code:
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
          <property name="jndiName" value="jdbc/mtk_poa_db"/>    
          <property name="resourceRef" value="true" /> 
    </bean>
    or you can use the tag in the jee namespace which uses JndiObjectFactoryBean underneath it

    <jee:jndi-lookup id="dataSource" jndi-name="jdbc/mtk_poa_db"/>

    Mark

  3. #3
    Join Date
    Nov 2011
    Posts
    18

    Default

    tried both way. But its not working ):

    Should I do some configaration in server.xml/ web.xml?
    Regards,
    Rajneesh

  4. #4
    Join Date
    Dec 2011
    Posts
    1

    Default

    Im having the same issue.. I have an app im porting from jboss to tomcat 7..

    my <catalina_home>/conf/server.xml:

    Code:
     <GlobalNamingResources>  
       <Resource 
         name="jdbc/PPDS" auth="Container"
         type="javax.sql.DataSource"
         driverClassName="oracle.jdbc.OracleDriver"
         url="jdbc:oracle:thin:@dev1vdb1:1541:cccd1"
         username="hidden" 
         password="hidden" 
         maxActive="20" 
         maxIdle="10"
         maxWait="-1"/>
      </GlobalNamingResources>
    my <catalina_home/conf/context.xml (I also tried putting this entry in my app/META-INF/context.xml and didn't help):

    Code:
    <Context>
        <ResourceLink global="jdbc/PPDS" name="jdbc/PPDS" type="oracle.jdbc.pool.OracleDataSource"/>
    </Context>
    my <app>/webroot/WEB-INF/appContext.xml:
    Code:
    <bean id="PCDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    	<property name="jndiName">
    			<value>jdbc/PPDS</value>
    	</property>
    </bean>
    I also tried using java:comp/env/jdbc/PPDS for the name and it didn't help.. This is pretty frustrating.. It shouldn't be this difficult

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •