I am trying to deploy a maven-built Java web app to Elastic Beanstalk, which is running an environment under the Amazon Linux Tomcat 7 version. The app works fine on localhost, even with an external mysql database (XEROUND).
My original context.xml has a resource as follows:
<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"
logAbandoned="true"
maxActive="100"
maxIdle="30"
maxWait="10000"
name="jdbc/xxxx-01292013"
password="xxxx"
removeAbandoned="true"
removeAbandonedTimeout="60"
type="javax.sql.DataSource"
url="jdbc:mysql://instancexxxx.db.xeround.com:xxxx/xxxx-01292013? autoReconnect=true"
username="xxxx-general"/>
However, when I run this app, I get the following error:
java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
I tried adding the following lines to my context.xml resource:
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
but that didn't work either. I then tried adding this line:
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
but that gives me the new exception:
javax.naming.NamingException: com.mysql.jdbc.Driver
I am pounding my head against a wall here, does anyone know what I can do to get this thing up and running?
Okay, so after some more experimentation and playing around with configurations, I have my app working by putting the following in my context.xml Resource tag:
and the following in my pom.xml file:
This answer was given to me at the AWS Forums here.
However, the better solution that I will be trying to get to work is by putting an .ebextensions file in my app, writing a .config file for it, and getting it to work that way. I think that this approach will be better suited long-term, as it will allow me to address any further configuration mis-match issues between my dev environment and elastic beanstalk's Tomcat 7. This solution is also laid out at the AWS Forums here, and here.