Configuring a MySQL JDBC persistence store in JBoss Fuse
henry.wong.ff Jan 5, 2015 5:07 PMHi everyone,
I am using JBoss Fuse 6.1.0.redhat-379 and successfully set up a fabric with a couple of child containers, i.e., brokers, that are setup in a Master-Slave cluster.
We are trying to persist messages in a JDBC persistence store like MySQL. Has anyone successfully done this before with JBoss Fuse 6.x.x?
So far, I have modified the broker.xml file for the base broker profile using the following command:
fabric:profile-edit --resource broker.xml mq-base
I changed the persistenceAdapter to not use Kahadb.
<persistenceAdapter>
<jdbcPersistenceAdapter dataDirectory="activemq-data" dataSource="#mysql-ds"/>
</persistenceAdapter>
I added a bean to specify my mysql datastore:
<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://<host machine>:3306/<schema name>"/>
<property name="username" value="<username>"/>
<property name="password" value="<password>"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
I ran the following command to add the Apache commons DBCP component:
fabric:profile-edit --bundles mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/1.2.2_6 mq-base
Now I am running into a problem on how to import MySQL JDBC driver. I am getting errors like the following:
2015-01-05 16:28:08,003 | ERROR | pool-19-thread-1 | ActiveMQServiceFactory | ceFactory$ClusteredConfiguration 452 | 114 - org.jboss.amq.mq-fabric - 6.1.0.redhat-379 | Exception on start: java.io.IOException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
java.io.IOException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:45)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:68)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.loadAdapter(JDBCPersistenceAdapter.java:451)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapter.java:434)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.java:383)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.init(JDBCPersistenceAdapter.java:295)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.broker.LockableServiceSupport.preStart(LockableServiceSupport.java:89)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:54)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.broker.BrokerService.doStartPersistenceAdapter(BrokerService.java:640)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.broker.BrokerService.startPersistenceAdapter(BrokerService.java:629)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:594)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
at org.fusesource.mq.fabric.ActiveMQServiceFactory$ClusteredConfiguration.org$fusesource$mq$fabric$ActiveMQServiceFactory$ClusteredConfiguration$$doStart(ActiveMQServiceFactory.scala:420)[114:org.jboss.amq.mq-fabric:6.1.0.redhat-379]
at org.fusesource.mq.fabric.ActiveMQServiceFactory$ClusteredConfiguration$$anon$4.run(ActiveMQServiceFactory.scala:368)[114:org.jboss.amq.mq-fabric:6.1.0.redhat-379]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_55]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_55]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_55]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_55]
at java.lang.Thread.run(Thread.java:744)[:1.7.0_55]
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1142)[136:org.apache.servicemix.bundles.commons-dbcp:1.2.2.6]
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:881)[136:org.apache.servicemix.bundles.commons-dbcp:1.2.2.6]
at org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:56)[96:org.apache.activemq.activemq-osgi:5.9.0.redhat-610379]
... 16 more
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in classloader xbean
at org.apache.xbean.classloader.MultiParentClassLoader.doLoadClass(MultiParentClassLoader.java:228)[110:org.apache.xbean.classloader:3.15.0]
at org.apache.xbean.classloader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:172)[110:org.apache.xbean.classloader:3.15.0]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_55]
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1135)[136:org.apache.servicemix.bundles.commons-dbcp:1.2.2.6]
... 18 more
Does anyone know how I should be loading the MySQL driver?
(I tried various things like putting the driver file in the lib/ext folders and in the deploy folder without any luck. I also tried looking in hawtio for a place to load the driver file, but couldn't find anything).
Thanks in advance for any help you can provide me,
Henry