Search code examples
mysqlamazon-web-servicesamazon-elastic-beanstalkdatanucleus

AWS Beanstalk to RDS issues with DataNucleus


I am trying to run a JSP file deployed to Amazon's Beanstalk, which uses DataNucleus to connect to RDS, and am getting the following error:

javax.jdo.JDOFatalDataStoreException: No suitable driver found for jdbc:mysql://mydbblahblah.rds.amazonaws.com:3306/mydb?autoReconnect=true

root cause

java.sql.SQLException: No suitable driver found for jdbc:mysql://bmydbblahblah.rds.amazonaws.com:3306/mydb?autoReconnect=true
    java.sql.DriverManager.getConnection(DriverManager.java:640)
    java.sql.DriverManager.getConnection(DriverManager.java:200)

Now I have the MySQL connector files in the classpath (it is at WebContent/WEB-INF/lib/mysql-connector-java-5.1.15-bin.jar, so this should work.

I have also confirmed that if I remove the library from there, I get the "com.mysql.jdbc.Driver not found on CLASSPATH" error.

Here is what my datanucleus.properties file looks like this:

javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.api.jdo.JDOPersistenceManagerFactory

javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:mysql://bmydbblahblah.rds.amazonaws.com:3306/mydb
#javax.jdo.option.ConnectionURL=jdbc:mysql://localhost:3306/mydb?autoReconnect=true
javax.jdo.option.ConnectionUserName=user
javax.jdo.option.ConnectionPassword=pwnothere

All of this works on my local Tomcat connecting to RDS. It only fails when running on Beanstalk.

Any ideas what might be causing this issue?

Thanks


Solution

  • So we downgraded to DataNucleus 2.0 without any other changes, and the issue disappeared. Sad, but it worked. I cannot recommend newer versions of DataNucleus with MySQL.