我正在尝试将应用程序从WebLogic迁移到Tomcat,但是在启动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
我在server.xml中的数据源定义如下;
<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>
也在context.xml中,如下所示;
<ResourceLink name="jdbc/datasource"
global="jdbc/datasource"
type="javax.sql.DataSource"/>
我该如何解决此问题?
答案 0 :(得分:0)
我找到了解决方案。在属性文件中有一个数据源定义,在该应用程序在tomcat context.xml中找到了jdbc定义后,我成功将其删除。