0
votes

i have a set up with 2 VPS's on the same linode (vps provider) data center. The are visible throught internal static ip's.

VPS.1.- Apache proxy, that is connected with VPS.2's tomcat using mod_jk.

I want VPS.2's tomcats spring application to use mysql database in VPS.1.

I tried changing META-INF/context.xml to pint to that database:

    <?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>

How ever i got the error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

Would somebody please throw some light to this dark matter ? Thank you!

1

1 Answers

0
votes

Yes, you have more work to do to set up that JNDI data source in Tomcat.

I'd recommend reading these:

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