Home » Clustering, Featured, Glassfish, How-to, Java, Mysql

Glassfish Enhanced Broker Cluster and “Failed to load JDBC driver”

14 April 2011 No Comment

Is not a bug, but a pretty annoying configuration thing which appear when you try to configure Enhanced Broker Cluster in Glassfish. I configured my persistent store, for Enhanced Broker Cluster, as jdbc / MySQL:

[…]
imq.persist.jdbc.dbVendor=mysql
imq.persist.jdbc.mysql.driver=com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
imq.persist.jdbc.mysql.property.url=jdbc\:mysql\://sqlserver\:3306/jms
imq.persist.jdbc.mysql.needpassword=true
imq.persist.jdbc.mysql.user=jms
[…]

and after at restart I got the following error:

[13/Apr/2011:12:12:30 CEST] [B1060]: Loading persistent data…
[13/Apr/2011:12:12:30 CEST] ERROR [B3198]: Error initializing cluster manager:
com.sun.messaging.jmq.jmsserver.util.BrokerException: [B3024]: Failed to load JDBC driver: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
at com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager.(DBManager.java:428)
at com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager.getDBManager(DBManager.java:219)
at com.sun.messaging.jmq.jmsserver.persist.jdbc.JDBCStore.(JDBCStore.java:98)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.sun.messaging.jmq.jmsserver.persist.StoreManager.getStore(StoreManager.java:157)
at com.sun.messaging.jmq.jmsserver.Globals.getStore(Globals.java:967)
at com.sun.messaging.jmq.jmsserver.cluster.ha.HAClusterManagerImpl.initialize(HAClusterManagerImpl.java:181)
at com.sun.messaging.jmq.jmsserver.Globals.initClusterManager(Globals.java:903)
at com.sun.messaging.jmq.jmsserver.Broker._start(Broker.java:777)
at com.sun.messaging.jmq.jmsserver.Broker.start(Broker.java:410)
at com.sun.messaging.jmq.jmsserver.Broker.main(Broker.java:1971)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.sun.messaging.jmq.jmsserver.persist.jdbc.DBManager.(DBManager.java:400)
… 15 more

To fix that just edit glassfish/imq/etc/imqenv.conf and add mysql driver to the jar path:

IMQ_DEFAULT_EXT_JARS=/opt/SUNWhadb/4/lib/hadbjdbc4.jar:/opt/SUNWjavadb/derby.jar:/usr/share/java/postgresql.jar:/home/user/glassfish/domains/domain1/lib/mysql-connector-java-5.1.10-bin.jar

And restart your cluster nodes.

Good Luck!


Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.