You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sasidharm <sa...@gmail.com> on 2009/10/11 21:24:02 UTC

Re: Bean endpoint in a route is holding reference to the last used methodName and does not use Camel's Bean binding for subsequent messages

Here is a test that illustrates the issue:

import javax.naming.Context;
import junit.framework.Assert;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.util.jndi.JndiContext;

public class CamelBeanEndpointTest extends ContextTestSupport {

	
    public void testRoute() throws Exception {
    	
        String stringBody = "stringBody";
		String stringResponse = (String)template.requestBody("direct:in",
stringBody);
        Assert.assertEquals(stringBody, stringResponse);
        
        Integer intBody = 1;
        Integer intResponse = (Integer)template.requestBody("direct:in",
intBody); //classcastexception
        Assert.assertEquals(1, intResponse.intValue());
    }
        
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
                from("direct:in").
                	to("bean:myBean");
            }
        };
    }

    @Override
    protected Context createJndiContext() throws Exception {
        JndiContext answer = new JndiContext();
        answer.bind("myBean", new MyBean());
        return answer;
    }
 
    public static class MyBean {
    	
    	public Integer intRequest(Integer request) {
    		return request;
    	}

    	public String stringRequest(String request) {
    		return request;
    	}
    	
    }
    
}

This unit test fails with a ClassCastException when using Camel 2.0. This
test passes for earlier versions of camel.

I am dead in the water right now, as our application has routes that depend
on camel's bean-binding mechanism. I would really appreciate if someone
could look into this issue.

Thanks,
Sasi
-- 
View this message in context: http://www.nabble.com/Bean-endpoint-in-a-route-is-holding-reference-to-the-last-used-methodName-and-does-not-use-Camel%27s-Bean-binding-for-subsequent-messages-tp25838095p25846696.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Bean endpoint in a route is holding reference to the last used methodName and does not use Camel's Bean binding for subsequent messages

Posted by Willem Jiang <wi...@gmail.com>.
The patch is committed into the SVN repository.
http://svn.apache.org/viewvc?rev=824218&view=rev

Willem

Willem Jiang wrote:
> Hi,
> 
> I just checked the change log of the code, this issue was introduced by 
> my change of  CAMEL-1777[1].
> So I created a JIRA[2] for it and will did a quick fix for it.
> 
> [1]http://issues.apache.org/activemq/browse/CAMEL-1777
> [2]http://issues.apache.org/activemq/browse/CAMEL-2060
> 
> Willem
> 
> sasidharm wrote:
>> Here is a test that illustrates the issue:
>>
>> import javax.naming.Context;
>> import junit.framework.Assert;
>> import org.apache.camel.ContextTestSupport;
>> import org.apache.camel.builder.RouteBuilder;
>> import org.apache.camel.util.jndi.JndiContext;
>>
>> public class CamelBeanEndpointTest extends ContextTestSupport {
>>
>>     
>>     public void testRoute() throws Exception {
>>        
>>         String stringBody = "stringBody";
>>         String stringResponse = (String)template.requestBody("direct:in",
>> stringBody);
>>         Assert.assertEquals(stringBody, stringResponse);
>>                 Integer intBody = 1;
>>         Integer intResponse = (Integer)template.requestBody("direct:in",
>> intBody); //classcastexception
>>         Assert.assertEquals(1, intResponse.intValue());
>>     }
>>             protected RouteBuilder createRouteBuilder() {
>>         return new RouteBuilder() {
>>             public void configure() {
>>                 from("direct:in").
>>                     to("bean:myBean");
>>             }
>>         };
>>     }
>>
>>     @Override
>>     protected Context createJndiContext() throws Exception {
>>         JndiContext answer = new JndiContext();
>>         answer.bind("myBean", new MyBean());
>>         return answer;
>>     }
>>  
>>     public static class MyBean {
>>        
>>         public Integer intRequest(Integer request) {
>>             return request;
>>         }
>>
>>         public String stringRequest(String request) {
>>             return request;
>>         }
>>        
>>     }
>>     }
>>
>> This unit test fails with a ClassCastException when using Camel 2.0. This
>> test passes for earlier versions of camel.
>>
>> I am dead in the water right now, as our application has routes that 
>> depend
>> on camel's bean-binding mechanism. I would really appreciate if someone
>> could look into this issue.
>>
>> Thanks,
>> Sasi
> 
> 


Re: Bean endpoint in a route is holding reference to the last used methodName and does not use Camel's Bean binding for subsequent messages

Posted by sasidharm <sa...@gmail.com>.
Thanks for looking into this. I will hold off upgrading to Camel 2.0 and wait
for this to be fixed in the Camel 2.1 release as this is a show stopper for
us.

Sasi


willem.jiang wrote:
> 
> Hi,
> 
> I just checked the change log of the code, this issue was introduced by 
> my change of  CAMEL-1777[1].
> So I created a JIRA[2] for it and will did a quick fix for it.
> 
> [1]http://issues.apache.org/activemq/browse/CAMEL-1777
> [2]http://issues.apache.org/activemq/browse/CAMEL-2060
> 
> Willem
> 
> sasidharm wrote:
>> Here is a test that illustrates the issue:
>> 
>> import javax.naming.Context;
>> import junit.framework.Assert;
>> import org.apache.camel.ContextTestSupport;
>> import org.apache.camel.builder.RouteBuilder;
>> import org.apache.camel.util.jndi.JndiContext;
>> 
>> public class CamelBeanEndpointTest extends ContextTestSupport {
>> 
>> 	
>>     public void testRoute() throws Exception {
>>     	
>>         String stringBody = "stringBody";
>> 		String stringResponse = (String)template.requestBody("direct:in",
>> stringBody);
>>         Assert.assertEquals(stringBody, stringResponse);
>>         
>>         Integer intBody = 1;
>>         Integer intResponse = (Integer)template.requestBody("direct:in",
>> intBody); //classcastexception
>>         Assert.assertEquals(1, intResponse.intValue());
>>     }
>>         
>>     protected RouteBuilder createRouteBuilder() {
>>         return new RouteBuilder() {
>>             public void configure() {
>>                 from("direct:in").
>>                 	to("bean:myBean");
>>             }
>>         };
>>     }
>> 
>>     @Override
>>     protected Context createJndiContext() throws Exception {
>>         JndiContext answer = new JndiContext();
>>         answer.bind("myBean", new MyBean());
>>         return answer;
>>     }
>>  
>>     public static class MyBean {
>>     	
>>     	public Integer intRequest(Integer request) {
>>     		return request;
>>     	}
>> 
>>     	public String stringRequest(String request) {
>>     		return request;
>>     	}
>>     	
>>     }
>>     
>> }
>> 
>> This unit test fails with a ClassCastException when using Camel 2.0. This
>> test passes for earlier versions of camel.
>> 
>> I am dead in the water right now, as our application has routes that
>> depend
>> on camel's bean-binding mechanism. I would really appreciate if someone
>> could look into this issue.
>> 
>> Thanks,
>> Sasi
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Bean-endpoint-in-a-route-is-holding-reference-to-the-last-used-methodName-and-does-not-use-Camel%27s-Bean-binding-for-subsequent-messages-tp25838095p25850540.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Bean endpoint in a route is holding reference to the last used methodName and does not use Camel's Bean binding for subsequent messages

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I just checked the change log of the code, this issue was introduced by 
my change of  CAMEL-1777[1].
So I created a JIRA[2] for it and will did a quick fix for it.

[1]http://issues.apache.org/activemq/browse/CAMEL-1777
[2]http://issues.apache.org/activemq/browse/CAMEL-2060

Willem

sasidharm wrote:
> Here is a test that illustrates the issue:
> 
> import javax.naming.Context;
> import junit.framework.Assert;
> import org.apache.camel.ContextTestSupport;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.util.jndi.JndiContext;
> 
> public class CamelBeanEndpointTest extends ContextTestSupport {
> 
> 	
>     public void testRoute() throws Exception {
>     	
>         String stringBody = "stringBody";
> 		String stringResponse = (String)template.requestBody("direct:in",
> stringBody);
>         Assert.assertEquals(stringBody, stringResponse);
>         
>         Integer intBody = 1;
>         Integer intResponse = (Integer)template.requestBody("direct:in",
> intBody); //classcastexception
>         Assert.assertEquals(1, intResponse.intValue());
>     }
>         
>     protected RouteBuilder createRouteBuilder() {
>         return new RouteBuilder() {
>             public void configure() {
>                 from("direct:in").
>                 	to("bean:myBean");
>             }
>         };
>     }
> 
>     @Override
>     protected Context createJndiContext() throws Exception {
>         JndiContext answer = new JndiContext();
>         answer.bind("myBean", new MyBean());
>         return answer;
>     }
>  
>     public static class MyBean {
>     	
>     	public Integer intRequest(Integer request) {
>     		return request;
>     	}
> 
>     	public String stringRequest(String request) {
>     		return request;
>     	}
>     	
>     }
>     
> }
> 
> This unit test fails with a ClassCastException when using Camel 2.0. This
> test passes for earlier versions of camel.
> 
> I am dead in the water right now, as our application has routes that depend
> on camel's bean-binding mechanism. I would really appreciate if someone
> could look into this issue.
> 
> Thanks,
> Sasi