Search code examples
tomcatdeploymentweblogicdatasource

Tomcat 8.5 Unable to find [jdbc]


I'm trying to migrate the application to from WebLogic to Tomcat but I'm getting below exception when starting tomcat.

Caused by: javax.naming.NameNotFoundException: Name [jdbc/datasource] is not bound in this Context. Unable to find [jdbc].
        at org.apache.naming.NamingContext.lookup(NamingContext.java:816)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:163)
        at javax.naming.InitialContext.lookup(InitialContext.java:417)
        at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
        at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
        at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
        at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
        at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
        at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        ... 60 more

My data source definition in server.xml as follow;

<GlobalNamingResources>
        <Resource name="jdbc/datasource" auth="Container" type="javax.sql.DataSource"
                  username="username" password="password"
                  driverClassName="oracle.jdbc.OracleDriver"
                  url="jdbc:oracle:thin:blablabla" />
</GlobalNamingResources>

Also in context.xml as follow;

<ResourceLink name="jdbc/datasource"
      global="jdbc/datasource"
      type="javax.sql.DataSource"/>

How can i resolve this issue?


Solution

  • I found the solution. There was a datasource definition in properties file and i deleted it, after that application was find the jdbc definition in in tomcat context.xml, successfully started.