我有以下情况:
- 我在 NetBeans 6.7 中有一个 Maven war 项目
- 我添加了 Tomcat 6.0 作为服务器,我用它来运行这个项目
- NetBeans 本身在 META-INF 目录中创建了 context.xml 文件,我在那里添加了 jdbc 资源,我确信它们是正确的。名字是'jdbc/defaultDS';
- 我检查了目标目录,context.xml 文件已正确复制。
- 我使用“java:comp/env/jdbc/defaultDS”作为 JNDI 位置来访问此数据源。
- 当我在 Tomcat 上运行这个项目时(conf/context.xml 中没有资源)我得到异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
我不知道发生了什么,感谢任何帮助。
最佳答案
最有可能的是 netbeans 以其自己的配置启动 tomcat,以便直接从 netbeans 集成项目。
关于web-applications - 为什么 Tomcat 从 netbeans 运行时会忽略 META-INF/context.xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1157704/