6 Replies Latest reply on Aug 5, 2009 8:25 AM by Dejan Bosanac

    Oracle JDBC driver installation for JDBC Master Slave setup

    joealex1 Newbie

      I am trying to set up a JDBC Master Slave as per http://activemq.apache.org/jdbc-master-slave.html with Fuse The modified portions of the deploy/activemq-broker.xml is below.


            Exception in thread "SpringOsgiExtenderThread-21" org.springframework.beans.factory.Bean

      CreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' de

      fined in URL bundle://47.0:0/META-INF/spring/activemq-broker.xml: Invocation of init method failed

      ; nested exception is java.io.IOException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleD


              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBe


              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean


              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(Abstra


              at java.security.AccessController.doPrivileged(Native Method)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(A


              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFac


              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(Defau


              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFacto


              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory


              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory


              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingle


              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitializ


              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.acc


              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.r


              at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUt


              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.com


              at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicati


              at java.lang.Thread.run(Thread.java:619)

      Caused by: java.io.IOException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'

              at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:45)

              at org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:6


              at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapte


              at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.j


              at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:1


              at org.apache.activemq.broker.BrokerService.start(BrokerService.java:463)

              at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:5


              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMe


              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBe


              ... 17 more

      Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.dr


              at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1141)

              at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

              at org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:5


              ... 24 more

      Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver not found from bundle [


              at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClass


              at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClass


              at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

              at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1134)

              ... 26 more

      Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

              at org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDelegation(Module


              at org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.java:59)

              at org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl


              at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

              at org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(ModuleImpl.java:4


              at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1354)

              at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:746)

              at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClass


              ... 29 more

        • 1. Re: Oracle JDBC driver installation for JDBC Master Slave setup
          Giovani Seben Newbie

          I think you need to wrap the oracle driver jar file so that it becomes a bundle and then place it in the deploy directory.


          The bnd tool should help you with that.



          • 2. Re: Oracle JDBC driver installation for JDBC Master Slave setup
            joealex1 Newbie

            Gio - Thanks will create the wrap with bnd and try.


            Meanwhile I used the OSGIfied oracle driver jar from Spring (older version though) http://www.springsource.com/repository/app/bundle/version/download?name=com.springsource.oracle.jdbc&version= and it worked.


            I have the ActiveMQ tables created in Oracle and messages are persisted and removed when read. Everything works great.


            Want to clarify something in the JDBC Master-Slave setup. Is this setup designed to run with one Master going up and down(typical is >1). ie in my case I have a Master starting up. ACTIVEMQ_LOCK table has a record with id=1 (time and broker_name is empty ?).


            When this Master goes down (Fuse is shutdown) is the record supposed to be removed. When I start Fuse back up ActiveMQ does not startup unless I manually delete this record and restart Fuse. Any suggestions.


            A 2 Broker scenario is what I am planning to use with the First broker holding the lock and when goes down releases the lock and the second broker will become Master and vice versa. Any docs explaining the locking/releasing mechanism will also be helpful.

            • 3. Re: Oracle JDBC driver installation for JDBC Master Slave setup
              Giovani Seben Newbie

              I'm not sure I fully understand your question. If you have only one broker using jdbc persistence then it's not a master-slave but a single broker setup. I have used this several times and didn't find the need to manually remove the lock record from the lock table.



              • 4. Re: Oracle JDBC driver installation for JDBC Master Slave setup
                joealex1 Newbie

                This is what I tried.


                1. Only one Broker




                First time works fine. Creates the tables. Becomes Master broker.  Inserts record in ACTIVEMQ_LOCKS table (where does it get the ID value ?)


                Now if you shutdown Fuse normally, the LOCK record does not get deleted. If you start back up All the tables are attempted to be created  (fails since exists) and then try to insert a record to LOCKS with ID=1. This fails with Unique constraint error.


                Sometimes you can delete the record manually, but at times you get the following error and will have to kill the session.

                ORA-00054: resource busy and acquire with NOWAIT specified


                With useDatabaseLock="false" I believe it does not lock ?


                2. Have 2 instances of Fuse running. All different ports. ActiveMQ is on 61616 and 61617 resp.


                Used the failover protocol



                Broker1 became master and tried some messages and worked fine. Shutdown Broker1, Broker2 became master and client connected back fine.


                Sometimes - when useDatabaseLock="false" the IDs generated by both Broker1 and 2 were different (chances of Primary key violation)


                But the behavior was not consistent - at times all the messages were read but was not deleted from the ACTIVEMQ_MSGS tables etc.


                Almost most of the time when the first Master went down the slave could not get the lock since the failed Master did not release it. IF you check the Oracle table ACTIVEMQ_LOCKS and try to delete manually you get

                ORA-00054: resource busy and acquire with NOWAIT specified


                Any help appreciated

                • 5. Re: Oracle JDBC driver installation for JDBC Master Slave setup
                  joealex1 Newbie

                  Looks like this is an open issue from last year :



                  Related http://issues.apache.org/activemq/browse/AMQ-1350



                  Not sure if there will be a fix or an alternate solution. Very critical in deciding on choosing Fuse

                  • 6. Re: Oracle JDBC driver installation for JDBC Master Slave setup
                    Dejan Bosanac Newbie



                    did you try to use standalone broker and see if you have the same behavior. It would be interesting to see if this is broker specific or has something to do with the Fuse environment (I mean shutting down the broker does not remove the lock).


                    BTW. I think your issues are not related to those Apache issues you're point to, since you're not loosing connection to the database.


                    If issues are still there with the standalone broker, it would be great if you could file the issue with the appropriate test case.