DemoSite/lib/mysql-connector-java-5.1.35-bin.jar Right place?
No.
And updated pom.xml with the following dependency...
This is fine if you are using the embedded Tomcat plugin that is kicked off via the ant tasks. For instance, if you are running nat tomcat or ant tomcat-jrebel then MySQL needs to be a dependency of the embedded Tomcat plugin (as the HSQL plugin is currently).
Yet, I get the following errors when attempting to run the application...
Instead of hardcoding the database username, password or URL directly in context.xml, we have these JNDI resource definitions set up to get this information from JVM arguments.
If you look in build.xml in the site and/or admin projects, you will see these JVM arguments being set up in the tomcat task prior to invoking tomcat7:run:
<target name="tomcat" depends="start-db">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Xmx512M" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" />
<jvmarg value="-javaagent:${spring.instrument.path}" />
<jvmarg value="-Druntime.environment=${runtime.environment}" />
<jvmarg value="-Ddatabase.user=${database.user}" />
<jvmarg value="-Ddatabase.password=${database.password}" />
<jvmarg value="-Ddatabase.driver=${database.driver}" />
<jvmarg value="-Ddatabase.url=${database.url}" />
<arg value="compile"/>
<arg value="war:exploded"/>
<arg value="tomcat7:run"/>
</artifact:mvn>
</target>
These jvmarg parameters:
<jvmarg value="-Ddatabase.user=${database.user}" />
<jvmarg value="-Ddatabase.password=${database.password}" />
<jvmarg value="-Ddatabase.driver=${database.driver}" />
<jvmarg value="-Ddatabase.url=${database.url}" />
popuplate those system properties from ant properties, in this order (look at the top of build.xml for this code):
Code: Select all
<!-- See the following URL for a description of this property file strategy -->
<!-- The only difference is we prepend a . for the home directory property files -->
<!-- http://www.javaranch.com/ant/properties.jsp -->
<property file="${user.home}/.${project.name}.properties"/>
<property file="${user.home}/.build.properties"/>
<property name="config.filename" value="${user.name}.properties"/>
<property file="config/${config.filename}"/>
<property file="../build.properties"/>
If you're building a war and running on a standalone Tomcat instance (which is what I think that you're doing) then this is what you need to do:
1. Copy the mysql connector jar
into the lib directory of Tomcat2. Ensure that the CATALINA_OPTS environment variable sets database.user, database.driver, database.password and database.url. This is commonly set in setenv.sh (linux/osx) or setenv.bat (windows):
Code: Select all
export CATALINA_OPTS="
-Ddatabase.url=jdbc:mysql://localhost:3306/broadleaf
-Ddatabase.user=readwriteuser
-Ddatabase.password=databasepassword
-Ddatabase.driver=com.mysql.jdbc.Driver
-Druntime.environment=development
-XX:MaxPermSize=512M
-Xmx1024M
-javaagent:/path/to/spring-instrument-4.1.6.RELEASE.jar"