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 4.1.0.2. 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

      river'

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

      an(AbstractAutowireCapableBeanFactory.java:1338)

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

      (AbstractAutowireCapableBeanFactory.java:473)

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

      ctAutowireCapableBeanFactory.java:409)

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

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

      bstractAutowireCapableBeanFactory.java:380)

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

      tory.java:264)

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

      ltSingletonBeanRegistry.java:222)

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

      ry.java:261)

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

      .java:185)

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

      .java:164)

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

      tons(DefaultListableBeanFactory.java:429)

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

      ation(AbstractApplicationContext.java:728)

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

      ess$1600(AbstractDelegatedExecutionApplicationContext.java:68)

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

      un(AbstractDelegatedExecutionApplicationContext.java:343)

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

      ils.java:85)

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

      pleteRefresh(AbstractDelegatedExecutionApplicationContext.java:308)

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

      onContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:138)

              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

      1)

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

      r.java:335)

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

      ava:279)

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

      75)

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

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

      6)

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

      thods(AbstractAutowireCapableBeanFactory.java:1369)

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

      an(AbstractAutowireCapableBeanFactory.java:1335)

              ... 17 more

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

      iver.OracleDriver'

              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

      4)

              ... 24 more

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

      activemq-broker.xml]

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

      Loader.java:103)

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

      Loader.java:156)

              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

      Impl.java:558)

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

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

      .java:1427)

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

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

      21)

              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

      Loader.java:99)

              ... 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.

           

          -Gio

          • 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=10.2.0.2 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.

               

              -Gio

              • 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

                failover:(tcp://localhost:61616,tcp://localhost:61617)?randomize=false&timeout=5000

                 

                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 :

                  http://issues.apache.org/activemq/browse/AMQ-1958

                   

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

                  https://issues.apache.org/activemq/browse/AMQ-1885

                   

                  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

                    Hi,

                     

                    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.