activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amichai Rothman (JIRA)" <>
Subject [jira] [Created] (AMQ-4776) ActiveMQ broker silently fails to start in Karaf
Date Wed, 02 Oct 2013 10:48:24 GMT
Amichai Rothman created AMQ-4776:

             Summary: ActiveMQ broker silently fails to start in Karaf
                 Key: AMQ-4776
             Project: ActiveMQ
          Issue Type: Bug
          Components: OSGi/Karaf
    Affects Versions: 5.8.0
         Environment: Kubuntu 64-bit, Oracle JDK 7u40, Karaf 2.3.3
            Reporter: Amichai Rothman

I have an application, deployed into Karaf. I install the activemq-broker feature, and one
of the app bundles uses ActiveMQConnectionFactory to get a javax.jms.Connection instance and
then uses the JMS API only (no other ActiveMQ-specific APIs in use). I'll note that this bundle
depends on another bundle which uses the JMS API as well (no ActiveMQ imports there at all).
The application also depends on other karaf features such as cxf-dosgi.

ActiveMQ fails to start in a couple of ways, depending on the order of installation of the
features and app:

At first I got a LinkageError:
java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.activemq.ActiveMQConnectionFactory.createConne
ction()Ljavax/jms/Connection;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader)
of the current
 class, com/myprojectgroup/bus/activemq/ActiveMQSession, and the class loader (instance of
efaultClassLoader) for resolved class, org/apache/activemq/ActiveMQConnectionFactory, have
different Class objects for the type Ljava
x/jms/Connection; used in the signature
        at com.myprojectgroup.bus.activemq.ActiveMQSession.createConnection(
        at com.myprojectgroup.messaging.jms.Session$[68:com.myprojectgroup.messaging:0.1.0.SNAPSHOT]

The only bundle that exports the javax.jms package is org.apache.geronimo.specs.geronimo-jms_1.1_spec,
though after further investigation I found that the activemq-web-console bundle does have
another copy of it internally, which I think might be the cause of the conflict (it does not
import the package in the manifest, so I can't just remove the package from the jar since
it won't find the package exported by the geronimo-jms bundle without a corresponding import
declaration). The activemq-osgi bundle has a DynamicImport-Package: *, which may further complicate
things. If it also had an explicit Import-Package directive for the statically-linked classes
it uses such as javax.jms ones, perhaps it would go through the regular bundle classloading
mechanism and avoid the problem - I think it takes precedence over dynamic imports, though
I'm not sure).

Next, I played around with reordering the installation, and got to another failure mode where
there is no exception at all or any error in the logs, but the broker simply fails to start
silently. Perhaps this is also caused by classloader issues but they are just occurring somewhere
within ActiveMQ and being silently ignored. This mode of failure I've managed to recreate

On a fresh stock installation of Karaf 2.3.3,  add two feature urls:
features:addurl mvn:org.apache.activemq/activemq-karaf/5.8.0/xml/features mvn:org.apache.cxf.dosgi/cxf-dosgi/1.6-SNAPSHOT/xml/features
(you might need to add the apache snapshot repo to karaf for it to find the dosgi snapshot
And then install them in this order:
features:install -v cxf-dosgi-discovery-distributed activemq-broker

The broker will not be started, although the logs will have no errors.
Strangely, if you now uninstall the activemq-web-console bundle (not feature) and restart
karaf, the broker will start ok. Also if you install only activemq-broker and not dosgi, it
will start ok.

To simplify, I found that instead of the dosgi feature it's enough to install and start the
mvn:org.osgi/org.osgi.compendium/4.3.1 bundle before installing activemq-broker to make it
fail - this is from looking at the innards of the dosgi feature, however if I remove this
bundle from the feature the broker still fails to start, so it's not the only bundle causing
problems, but just an example.

The only workaround I've found so far is to install everything, then uninstall the activemq-web-console
bundle and restart - then everything works as it should. Strangely, not installing it in the
first place doesn't work either - the broker won't start unless the web console is first started,
then uninstalled.

Some details of the LinkageError are in (pasted to karaf irc
channel originally).

This message was sent by Atlassian JIRA

View raw message