camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marek Kasztelnik <ymkas...@cyfronet.pl>
Subject xpath problem when creating own camelcontex inside osgi
Date Wed, 12 Jan 2011 13:14:18 GMT
Hej,

I have a problem with xpath when creating own camel context (e.g. in 
activator) inside osgi container (karaf). Following code:

public void start( BundleContext bc ) throws Exception {
         ccontext = new DefaultCamelContext();
         ccontext.addComponent("jms", 
getActiveMqJmsComponent("username", "pass", "failover://tcp://url"));
         try {
             ccontext.addRoutes(new RouteBuilder() {

                 @Override
                 public void configure() throws Exception {
                     Namespaces ns = new Namespaces("", "");
                     final XPathExpression testXpathExpression = ns
                             .xpath("/result/sensor_id/text()");

                     from("jms://topic:myTopic").process(new Processor() {

                         public void process(Exchange exchange) throws 
Exception {
                             System.out.println("test1: >" + 
testXpathExpression.evaluate(exchange)+ "<");
                             System.out.println("test2: >" + 
testXpathExpression.evaluate(exchange, Integer.class)+ "<");
                         }
                     });
                 }
             });
             ccontext.start();
         } catch (Exception e) {
             e.printStackTrace();
         }
         System.out.println("started");
     }

returns:

test: >com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList@1b993d6<
test: >null<

instead of 12 when sending:

<?xml version="1.0" encoding="UTF-8"?>
<result>
<sensor_id>12</sensor_id>
</result>

to myTopic topic.

12 is returned, when I create standalone application or create camel 
context using spring inside osgi budnel. Anyone know why creating own 
camel context inside osgi causes  so strange behaviour?


I'm using following configuration:

karaf@root> version
Major                2
Micro                1
Minor                1
Qualifier


[installed  ] [2.5.0        ] camel                    repo-0
[installed  ] [2.5.0        ] camel-core               repo-0
[installed  ] [2.5.0        ] camel-spring             repo-0
[installed  ] [2.5.0        ] camel-jms                repo-0


Mime
View raw message