Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-5083

Camel cannot auto create JPA component if Karaf has installed spring-orm feature

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • jboss-fuse-6.3
    • jboss-fuse-6.3
    • Camel
    • None
    • % %
      1. features:install spring-orm
      2. build and deploy reproducer (Instructions in Readme file)
    • 6.3 Sprint 3 (Feb 29 - Mar 25)

      Unable to create JPA component if spring-orm feature is already intalled on Karaf. The problem occurs when camel obtaining Transaction Manager through OSGi Service registry. It throws this exception:

      Caused by: org.apache.camel.RuntimeCamelException: Cannot auto create component: jpa
      	at org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:412)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	at org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:388)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:560)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	... 39 more
      Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: Cannot cast org.apache.aries.transaction.internal.AriesPlatformTransactionManager to org.springframework.transaction.PlatformTransactionManager
      	at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1642)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	at org.apache.camel.core.osgi.OsgiServiceRegistry.findByTypeWithName(OsgiServiceRegistry.java:115)[233:org.apache.camel.camel-blueprint:2.16.1.redhat-630026]
      	at org.apache.camel.impl.CompositeRegistry.findByTypeWithName(CompositeRegistry.java:91)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.findByTypeWithName(PropertyPlaceholderDelegateRegistry.java:70)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	at org.apache.camel.component.jpa.JpaComponent.doStart(JpaComponent.java:139)[330:org.apache.camel.camel-jpa:2.16.1.redhat-630026]
      	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3232)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	at org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:407)[229:org.apache.camel.camel-core:2.16.1.redhat-630026]
      	... 41 more
      Caused by: java.lang.ClassCastException: Cannot cast org.apache.aries.transaction.internal.AriesPlatformTransactionManager to org.springframework.transaction.PlatformTransactionManager
      	at java.lang.Class.cast(Class.java:3369)[:1.8.0_45]
      	at org.apache.camel.core.osgi.OsgiServiceRegistry.findByTypeWithName(OsgiServiceRegistry.java:107)[233:org.apache.camel.camel-blueprint:2.16.1.redhat-630026]
      	... 47 more
      

      I discover that the problem is that two versions of Spring are installed because camel-jpa component requires Spring 3.2.x but default version has changed on Spring 4.1.x.. This problem may occur when migrating existing applications. I thing that it is necessary to align versions of Spring otherwise it is possible that a similar problem may also occur in other combinations.

      JBossFuse:karaf@root> features:info spring-orm
      Description of spring-orm 4.1.7.RELEASE_1 feature
       Spring 4.1.x ORM support
      
      features:info camel-jpa 
      Description of camel-jpa 2.16.1.redhat-630026 feature
      ----------------------------------------------------------------
      Feature has no configuration
      Feature has no configuration files
      Feature depends on:
        spring-tx [3.2,4)
        spring-jdbc [3.2,4)
        spring-orm [3.2,4)
        camel-core 2.16.1.redhat-630026
      

            lburgazz@redhat.com Luca Burgazzoli
            tturek@redhat.com Tomas Turek
            Tomas Turek Tomas Turek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: