On Tue, May 31, 2011 at 5:18 PM, sumatheja <[email protected]> wrote: > Hi Claus, > Thanks for the help. But when i try to run my code its throwing > the following exception > > Exception in thread "main" 2011-05-31 20:44:29,313 [Thread-1 ] INFO > MainSupport$HangupInterceptor - Received hang up - stopping the main > instance. > org.apache.camel.CamelException: Cannot find any Camel Context from the > Application Context. Please check your Application Context setting > at
Hi it looks like you are using the Main class from camel-spring. And it expects you define a <camelContext> in the Spring XML file. If you do not want to do that, eg just start Camel from only Java code (no Spring) then use the Main class from camel-core. Its all explained here http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html > org.apache.camel.impl.MainSupport.postProcessContext(MainSupport.java:371) > at org.apache.camel.spring.Main.doStart(Main.java:144) > at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67) > at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54) > at org.apache.camel.impl.MainSupport.run(MainSupport.java:136) > at camelinaction.FinalCSVParser.main(FinalCSVParser.java:56) > > Given below is my code. Can you please let me know where i'm going wrong?? > > public class FinalCSVParser { > > > public static void main(String[] args) throws Exception { > > Main main = new Main(); > main.enableHangupSupport(); > > main.setApplicationContextUri("META-INF/spring/camel-context.xml") ; > main.addRouteBuilder(new RouteBuilder() { > public void configure() throws Exception { > from("file:src/data?delay=10000&noop=true") > .unmarshal().bindy(BindyType.Csv, > "camelinaction") > .process(new Processor(){ > public void process(Exchange > exchange) throws > Exception { > List listin = > exchange.getIn().getBody(List.class); > List<PurchaseOrder> > listout = new > ArrayList<PurchaseOrder>(); > > System.out.println(listin.size()); > int i = 0; > for (i=0; > i<listin.size(); i++){ > Map row > = (Map) listin.get(i); > > System.out.println(row.size()); > > listout.add((PurchaseOrder)row.get(PurchaseOrder.class.getName())); > } > > System.out.println(listout.size()); > > exchange.getIn().setBody(listout); > > } > > }) > .split(body()) > > .to("jpa:camelinaction.PurchaseOrder"); > > > } > }); > main.run(); > > } > } > > > Thanks in advance. > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/File-Poller-tp4435442p4442309.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: [email protected] Web: http://fusesource.com CamelOne 2011: http://fusesource.com/camelone2011/ Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
