unresolved dependency on (objectClass=org.springframework.transaction.PlatformTransactionManager)

Solution Verified - Updated -

Environment

  • Fuse ESB
    • 4.4
  • Fuse ESB Enterprise
    • 7.x
  • Red Hat JBoss Fuse
    • 6.0.0

Issue

  • When deploying a Camel route that uses the Aries transaction manager the route won't start. The ESB log contains
ERROR | rint Extender: 2 | BlueprintContainerImpl  | 10 - org.apache.aries.blueprint - 0.3.1 | Unable to start blueprint container for bundle camel-context.xml due to unresolved dependencies [(objectClass=org.springframework.transaction.PlatformTransactionManager)]
  • We're finding that fabric refuses to deploy because it cannot find an 'Export-Service' manifest entry for 'org.springframework.transaction.PlatformTransactionManager'

  • After shutting down fuse it no longer starts due to the error
    unsatisfied dependencies: Dependency on [(objectClass=org.springframework.transaction.PlatformTransactionManager)]

    We have seen this a number of times in our dev environments, and have usually been able to get it to start by deleting the activemq data directory (i.e. deleting messages). It would appear to
    happen more frequently the more messages we have. We now need a proper solution for getting fuse to start.

Resolution

For Fuse ESB 4.4 and Fuse ESB Enterprise 7.x

To resolve this, you will need to run an osgi:refresh and verify using an osgi:ls that it now also exports its service under the interface org.springframework.transaction.PlatformTransactionManager.

osgi:ls 53

Apache Aries Transaction Manager (53) provides:
-----------------------------------------------
objectClass = org.osgi.service.cm.ManagedService
service.id = 262
service.pid = org.apache.aries.transaction
----
objectClass = javax.transaction.TransactionManager, javax.transaction.TransactionSynchronizationRegistry, javax.transaction.UserTransaction, org.apache.geronimo.transaction.manager.RecoverableTransactionManager, org.springframework.transaction.PlatformTransactionManager
service.id = 273

For JBoss Fuse 6.0

Athe following to the maven felix plugin configuration, which stops the ExportService from being generated:

<_removeheaders>Import-Service</_removeheaders>

Root Cause

Fuse ESB 4.4, and Fuse ESB Enterprise 7.x

This can happen at start up time because the Aries transaction manager only has an optional dependency on the spring-tx bundle. This optional dependency is by design.
So Aries won't wait until the spring-tx is started. If spring-tx is not yet started when Aries starts, Aries won't export its service under the org.springframework.transaction.PlatformTransactionManager interface. Therefore any other bundles that resolve the transaction manager using the org.springframework.transaction.PlatformTransactionManager interface will not start and wait for this service to become available or eventually time out.

JBoss Fuse 6.0

The Import-Service and Export-Service have been deprecated in favor of dynamic service registration (since service can become available and unavailable at any time) while the Import-Service and Export-Service only register and reference service statically. Please see this link:
http://wiki.osgi.org/wiki/Import-Service

For instance, you just need to expose OSGi service like described in this link:
http://aries.apache.org/modules/blueprint.html

    <service id="accountService"  interface="org.apache.aries.simple.Account">
      <bean class="org.apache.aries.simple.AccountImpl" />
   </service> 

Then in your consumer bundle, you can configure reference to get a reference on above service:

<reference id="accountRef" interface="org.apache.aries.simple.Account"/>

then pass it to your client bean:

   <bean id="accountClient" class="org.apache.aries.simple.AccountClient">
       <property name="account" ref="accountRef" />
   </bean>

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments