camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Wu(Geckos)" <>
Subject AdviceWithRouteBuider issue
Date Fri, 16 Aug 2013 07:09:19 GMT
Hi Camel team folks
I try to try to write code with tests AdviceWithRouteBuilder's explored API base on Camel
2.11 version, but got below error, please kindly help it, thanks  a lot.
I really refer to camel website listed guide line.

You can of course combine those in the same advice with:
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
    public void configure() throws Exception {

Source code:
public class TestAdviceRoute extends AdviceWithRouteBuilder {

	public void configure() throws Exception {

		this.getContext().getRouteDefinitions().get(0).adviceWith(this.getContext(), new AdviceWithRouteBuilder()
		    public void configure() throws Exception {
		        weaveAddFirst().to("mock:input").process( new PrintProcessor());

		.process(new PrintProcessor())

	private final static class PrintProcessor extends SoSSProcessor{

		public void sossProcess(Exchange exchange) throws Exception {
			System.out.println("exchange zdfasfas : "+ exchange);
	public static void main(String[] args) throws Exception{
		CamelContext context = new DefaultCamelContext();
		context.addRoutes(new TestAdviceRoute());
//		AdvicesRouteTest advicesRouteTest = new AdvicesRouteTest();
//		System.out.println(context.getRouteDefinitions().get(0));
//		advicesRouteTest.setOriginalRoute(context.getRouteDefinitions().get(0));
//		context.addRoutes(advicesRouteTest);
		context.createProducerTemplate().sendBody("direct:start", "asdfasfdsaf");


Got Exception:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(
	at java.util.ArrayList.get(
	at com.getusroi.soss.route.impl.TestAdviceRoute.configure(
	at org.apache.camel.builder.RouteBuilder.checkInitialized(
	at org.apache.camel.builder.RouteBuilder.configureRoutes(
	at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(
	at org.apache.camel.impl.DefaultCamelContext.addRoutes(
	at com.getusroi.soss.route.impl.TestAdviceRoute.main(

Best Regards

Bleum Incorporated
George Wu                                                                                 
Cloud-9 Mansion 7F
1118 West Yan'an Road.
Shanghai, P.R.C. 200052

This email may contain confidential information and/or copyright material. This email and
any attachments are solely for the intended recipient.
If you are not the intended recipient, disclosure, copying, use or distribution of the information
included in this message may be unlawful. please advise the sender immediately by using the
reply facility in your email software, and immediately and permanently delete. 
Thank you for your cooperation.

  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message