【问题标题】:Remote transactions with hibernate+spring+mysql using tomcat?使用tomcat与hibernate + spring + mysql进行远程事务?
【发布时间】:2011-11-15 18:58:54
【问题描述】:

我在同一个 linode(vps 提供商)数据中心上设置了 2 个 VPS。通过内部静态 ip 可见。

VPS.1.- Apache 代理,使用 mod_jk 与 VPS.2 的 tomcat 连接。

我想让VPS.2的tomcats spring应用在VPS.1中使用mysql数据库。

我尝试将 META-INF/context.xml 更改为指向该数据库:

    <?xml version="1.0" encoding="UTF-8"?>
<Context path="/" override="true" reloadable="false" swallowOutput="false">

    <Resource name="jdbc/catWDB" auth="Container" type="javax.sql.DataSource"
              driverClassName="com.mysql.jdbc.Driver"
              factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"

url="jdbc:mysql://VPS.1_IP:3306/database_name?zeroDateTimeBehavior=convertToNull&amp;autoReconnect=true"
              username="user_name"
              password="pass_name"
              validationQuery="select 1"
              maxActive="20"
              maxIdle="10"
              maxWait="-1"/>
</Context>

我是怎么得到错误的:

org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中创建名称为“dataSource”的 bean 时出错:调用 init 方法失败;嵌套异常是 javax.naming.NameNotFoundException: Name jdbc is not bound in this Context 造成的: javax.naming.NameNotFoundException:名称 jdbc 未绑定在此上下文中

请有人给这个暗物质一些启示吗?谢谢!

【问题讨论】:

    标签: mysql hibernate spring tomcat


    【解决方案1】:

    是的,您需要做更多工作才能在 Tomcat 中设置该 JNDI 数据源。

    我建议阅读以下内容:

    http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html http://craicpropagation.blogspot.com/2009/02/how-to-use-same-jndi-resource-name-on.html

    【讨论】:

      猜你喜欢
      • 2011-08-04
      • 2011-08-05
      • 1970-01-01
      • 1970-01-01
      • 2012-10-17
      • 2011-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多