javax.naming.NameNotFoundException:Name[ XXX] is not bound in this context.

时间:2023-03-08 23:43:42
javax.naming.NameNotFoundException:Name[ XXX] is not bound in this context.

在用局部数据源去连数据库的时候,在本地的项目中,都是可以的,可是一部署到服务器上,就报错了。

报的错误是:javax.naming.NameNotFoundException:Name[ XXX] is not bound in this context.

javax.naming.NameNotFoundException:Name[ XXX] is not bound in this context.

查了下解决方案:在项目的web.xml中加入下面的代码

 <resource-ref>
<description>DB Connection</description>
<res-ref-name>zjut_echarts</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

加入以后呢,这个错误是消失了,但是又来了一个新的错误。

javax.naming.NameNotFoundException:Name[ XXX] is not bound in this context.

怎么办,好呢?目前的解决方案是:C:\apache-tomcat-7.0.37\conf目录下面的context.xml删掉,把我们项目中的META-INF目录下的context.xml文件复制到C:\apache-tomcat-7.0.37\conf目录下