JNDI DataSource with Tomcat 6 and Eclipse

Viewed 26032

I can't get my DataSource working with JNDI and Tomcat 6, while running it from Eclipse. I've added a context.xml to my /META-INF with the following content:

<Context>

<Resource name="jdbc/myDB" auth="Container" type="javax.sql.DataSource"
     username="root"
     password="root"
     driverClassName="com.mysql.jdbc.Driver"
     url="jdbc:mysql://localhost/database"
     maxActive="15"
     maxIdle="7"
     validationQuery="Select 1" />
</Context>

And configured my Spring Bean as follows:

<bean id="UserDatabase" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/myDB"></property>
    <property name="lookupOnStartup" value="true"></property>
    <property name="cache" value="true"></property>
    <property name="proxyInterface" value="javax.sql.DataSource"></property>
</bean>

I've also added this lines to my web.xml:

<resource-ref>
    <description>Connection Pool</description>
    <res-ref-name>jdbc/myDB</res-ref-name>
    <res-type>javax.sql.Datasource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

But for some reason I still get this error:

javax.naming.NameNotFoundException: The name jdbc is not associated to this context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)

I can't understand why this is not working... Any idea?

3 Answers
Related