简体   繁体   English

在上下文文件中配置Tomcat 7 JDNI数据源时出现问题

[英]Issue configuring Tomcat 7 JDNI datasource in Context file

This is the exception that I get: 这是我得到的例外:

Error creating bean with name 'jndiDataSource' defined in class path resource [spring/database.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [connection_pool] is not bound in this Context. Unable to find [connection_pool]

This is my datasource bean: 这是我的数据源bean:

<bean id="jndiDataSource"
      class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="connection_pool" />
</bean>

This is my context file MyApp##1.0.2.xml that I dropped into tomcat7/conf/Catalina/localhost : 这是我放入tomcat7/conf/Catalina/localhost上下文文件MyApp##1.0.2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="path\to\war\my-app-1.0.2.war"
    antiResourceLocking="false" privileged="true" >

<Resource name="connection_pool" 
            url="jdbc:mysql://localhost:3306/db_name"
            driverClassName="com.mysql.jdbc.Driver"
            username="username" password="password" 
            auth="Container" type="javax.sql.DataSource"
            maxActive="100" maxIdle="30" maxWait="10000" />

</Context>

Does anyone have any ideas of why this is not working? 有谁知道为什么它不起作用?

请尝试此操作,它应提供正确的配置:

<jee:jndi-lookup id="myDataSource" jndi-name="java:connection_pool" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM