0 Replies Latest reply on Jan 16, 2014 5:25 AM by andr2ot

    Problem with class visibility between camel bundles

    andr2ot

      I am having problems with with class visibility between osgi bundles when using camel 2.12 and 2.13-SNAPSHOT. I have created a showcase to reproduce the problem based on camel example projects. I have tested the created solution in camel 2.10 and problem does not exist there which suggests to me it is a bug. Could somebody confirm that it is indeed the case?


       

      Currently I have two projects:

      - camel-example-osgi -  Slightly modified version of example project

      - camel-example-osgi-domain - new project containing only domain classes required by different osgi projects

       

      So essentially the camel-example-osgi-domain is place holder for domain objects.


       org.apache.camel.example.osgi.domain.MyPojo
      public class MyPojo  implements Serializable { 
          private String id; 
      
          public MyPojo(String id){ 
          this.id =id; 
          } 
      
          public String getId() { 
              return id; 
          } 
        
      } 
      
      
      
      


      camel-example-osgi defines camel route with two routes:

      <?xml version="1.0" encoding="UTF-8"?> 
      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:camel="http://camel.apache.org/schema/spring"
             xsi:schemaLocation=" 
               http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
               http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
      
        
        <camelContext xmlns="http://camel.apache.org/schema/spring">
      
              <route>
            <from uri="timer://mytestTrigger?fixedRate=true&amp;period=10000"/>
            <to uri="myTestFactory"/>
          </route>
          <route id="mvelTest">
            <from uri="seda://myMvelTest?concurrentConsumers=2"/>
            <choice>
            <when>
              <mvel>request.body instanceof org.apache.camel.example.osgi.MyPojo</mvel>
            <to uri="log:MvelRouter"/>
            </when>          
            </choice>
          </route>
              
        </camelContext>
      
        <bean id="myTestFactory" class="org.apache.camel.example.osgi.MyTestFactory">
          <property name="numberOfMessages" value="2"/>
        </bean>
      
      </beans>
      
      
      
      

       

       

       

      So as you can see the camel-example-osgi project depends on camel-example-osgi-domain due to MyPojo class. Therefore to make it work in karaf I have configured two feature.xml files for each project:

       

      camel-example-osgi - feature.xml :


      <features>
          <repository>mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features</repository>
          
          <feature name='camel-example-osgi' version='${project.version}'>
              <feature version="${project.version}">camel-example-osgi-domain</feature>
              <feature version="${project.version}">camel-spring</feature>
              <feature version="${project.version}">camel-mvel</feature>
              <bundle>mvn:org.apache.camel/camel-example-osgi/${project.version}</bundle>
          </feature>
      
      </features>
      
      
      
      

       

      camel-example-osgi-domain - feature.xml :

          <feature name='camel-example-osgi-domain' version='${project.version}'>
              <bundle>mvn:org.apache.camel/camel-example-osgi-domain/${project.version}</bundle>
          </feature>
      
      

       

       

      When I deploy both feature to karaf and place a message on seda://myMvelTest?concurrentConsumers=2 queue i get following exception in karaf.

       

      ERROR | eda://myMvelTest | DefaultErrorHandler              | rg.apache.camel.util.CamelLogger  215 | 73 - org.apache.camel.camel-core - 2.13.0.SNAPSHOT | Failed delivery for (MessageId: ID-localhost-51000-1389691121739-1-56 on ExchangeId: ID-localhost-51000-1389691121739-1-85). Exhausted after delivery attempt: 1 caught: org.apache.camel.ExpressionEvaluationException: [Error: could not access: org; in class: org.apache.camel.language.mvel.RootObject]

      [Near : {... est.body instanceof org.apache.camel.example.osgi. ....}]

                                       ^

      [Line: 1, Column: 25]

       

      Message History

      ---------------------------------------------------------------------------------------------------------------------------------------

      RouteId              ProcessorId          Processor                                                                        Elapsed (ms)

      [mvelTest          ] [mvelTest          ] [seda://myMvelTest?concurrentConsumers=2                                       ] [        14]

      [mvelTest          ] [choice2           ] [when[mvel{Mvel[request.body instanceof org.apache.camel.example.osgi.MyPojo]}]] [         0]

       

      Exchange

      ---------------------------------------------------------------------------------------------------------------------------------------

      Exchange[

              Id                  ID-localhost-51000-1389691121739-1-85

              ExchangePattern     InOut

              Headers             {breadcrumbId=ID-localhost-51000-1389691121739-1-56, CamelRedelivered=false, CamelRedeliveryCounter=0}

              BodyType            org.apache.camel.example.osgi.MyPojo

              Body                org.apache.camel.example.osgi.MyPojo@21093d9e

      ]

       

      Stacktrace

      ---------------------------------------------------------------------------------------------------------------------------------------

      org.apache.camel.ExpressionEvaluationException: [Error: could not access: org; in class: org.apache.camel.language.mvel.RootObject]

      [Near : {... est.body instanceof org.apache.camel.example.osgi. ....}]

                                       ^

      [Line: 1, Column: 25]

              at org.apache.camel.language.mvel.MvelExpression.evaluate(MvelExpression.java:60)[103:org.apache.camel.camel-mvel:2.13.0.SNAPSHOT]

              at org.apache.camel.support.ExpressionSupport.matches(ExpressionSupport.java:32)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:90)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:291)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:200)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:147)[73:org.apache.camel.camel-core:2.13.0.SNAPSHOT]

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)[:1.6.0_65]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)[:1.6.0_65]

              at java.lang.Thread.run(Thread.java:695)[:1.6.0_65]

      Caused by: [Error: could not access: org; in class: org.apache.camel.language.mvel.RootObject]

      [Near : {... est.body instanceof org.apache.camel.example.osgi. ....}]

                                       ^

      [Line: 1, Column: 25]

              at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:683)[102:org.mvel2:2.1.7.Final]

              at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:337)[102:org.mvel2:2.1.7.Final]

              at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)[102:org.mvel2:2.1.7.Final]

              at org.mvel2.optimizers.dynamic.DynamicOptimizer.optimizeAccessor(DynamicOptimizer.java:67)[102:org.mvel2:2.1.7.Final]

              at org.mvel2.ast.ASTNode.optimize(ASTNode.java:159)[102:org.mvel2:2.1.7.Final]

              at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115)[102:org.mvel2:2.1.7.Final]

              at org.mvel2.ast.Instance.getReducedValueAccelerated(Instance.java:21)[102:org.mvel2:2.1.7.Final]

              at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:42)[102:org.mvel2:2.1.7.Final]

              at org.mvel2.MVEL.executeExpression(MVEL.java:954)[102:org.mvel2:2.1.7.Final]

              at org.apache.camel.language.mvel.MvelExpression.evaluate(MvelExpression.java:57)[103:org.apache.camel.camel-mvel:2.13.0.SNAPSHOT]

       

       

      Exception suggest that camel-example-osgi is not able to resolve camel-example-osgi-domain classes.

       

      Did anybody run into similar problem with osgi bundles deployed to apache-karaf-2.3.3? Any ideas how to resolve that.

       

      Please see the MANIFEST.MF files for both projects:

       

      Manifest-Version: 1.0

      Bnd-LastModified: 1389700746555

      Build-Jdk: 1.7.0_25

      Built-By: amajewski

      Bundle-Description: A simple OSGi example which creates a bundle that ca

      n be dropped into any OSGi container

      Bundle-DocURL: http://www.apache.org/

      Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt

      Bundle-ManifestVersion: 2

      Bundle-Name: camel-example-osgi

      Bundle-SymbolicName: camel-example-osgi

      Bundle-Vendor: The Apache Software Foundation

      Bundle-Version: 2.13.0.SNAPSHOT

      Created-By: Apache Maven Bundle Plugin

      Export-Package: org.apache.camel.example.osgi;uses:="org.apache.camel.bu

      ilder,org.apache.camel.model,org.apache.camel.spring,org.apache.camel,o

      rg.apache.camel.example.osgi.domain,org.slf4j";version="2.13.0.SNAPSHOT

      ",org.apache.camel.example.osgi.domain;version="2.13.0.SNAPSHOT"

      Implementation-Title: Apache Camel

      Implementation-Version: 2.13-SNAPSHOT

      Import-Package: org.apache.camel;version="[2.13,3)",org.apache.camel.bui

      lder;version="[2.13,3)",org.apache.camel.example.osgi.domain;version="[

      2.13,3)",org.apache.camel.model;version="[2.13,3)",org.apache.camel.spr

      ing;version="[2.13,3)",org.slf4j;version="[1.6,2)"

      Karaf-Info: Camel;camel-example-osgi=2.13-SNAPSHOT

      Tool: Bnd-1.50.0

       

       

       

      Manifest-Version: 1.0

      Bnd-LastModified: 1389700566679

      Build-Jdk: 1.7.0_25

      Built-By: amajewski

      Bundle-Description: Camel Examples

      Bundle-DocURL: http://www.apache.org/

      Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt

      Bundle-ManifestVersion: 2

      Bundle-Name: camel-example-osgi-domain

      Bundle-SymbolicName: camel-example-osgi-domain

      Bundle-Vendor: The Apache Software Foundation

      Bundle-Version: 2.13.0.SNAPSHOT

      Created-By: Apache Maven Bundle Plugin

      Export-Package: org.apache.camel.example.osgi.domain;version="2.13.0.SNA

      PSHOT"

      Implementation-Title: Apache Camel

      Implementation-Version: 2.13-SNAPSHOT

      Karaf-Info: Camel;camel-example-osgi-domain=2.13-SNAPSHOT

      Tool: Bnd-1.50.0