camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiangqiuzhao <xiangqiuz...@gmail.com>
Subject set encoder in netty exception
Date Mon, 09 Jan 2012 08:23:48 GMT
<bean id="myencoder"
class="org.jboss.netty.handler.codec.string.StringEncoder"/>

my code like:

ApplicationContext appctx =
            new
ClassPathXmlApplicationContext("/org/apache/camel/component/netty/test-codecs.xml");
        Object decoder = appctx.getBean("mydecoder");
        Object encoder = appctx.getBean("myencoder");
        
        SimpleRegistry registry = new SimpleRegistry(); 
        registry.put("myDecoder", decoder); 
        registry.put("myEncoder", encoder); 
        CamelContext context = new DefaultCamelContext(registry);

        context.addRoutes(new RouteBuilder() {
            public void configure() throws Exception {
                from("direct:cpsp")
                .process(new MyToProcessor())
               
.to("netty:tcp://localhost:4096?sync=true&encoder=#myEncoder")
                .process(new MyFromProcessor());
            }
        });
        
        context.start();
        
        Endpoint endpoint = context.getEndpoint("direct:cpsp");
        Exchange exchange = endpoint.createExchange();
        byte[] data = FileUtil.getInputStreamContent(new
FileInputStream("D:/a.xml"));
        
        Producer producer = endpoint.createProducer();
        exchange.getIn().setBody(new String(data).trim());
        producer.process(exchange);
        if (exchange.getException() != null)
            throw exchange.getException();
        
        System.out.println(exchange.getOut().getBody());


but exception with:



Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint:
netty://tcp://localhost:4096?encoder=%23myEncoder&sync=true due to: Could
not find a suitable setter for property: encoder as there isn't a setter
method with same type: java.lang.String nor type conversion possible: No
type converter available to convert from type: java.lang.String to the
required type: org.jboss.netty.channel.ChannelDownstreamHandler with value
#myEncoder
	at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:450)
	at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:47)
	at
org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:180)
	at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:110)
	at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
	at
org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:61)
	at
org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:55)
	at
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:410)
	at
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:181)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:812)
	... 9 more
Caused by: java.lang.IllegalArgumentException: Could not find a suitable
setter for property: encoder as there isn't a setter method with same type:
java.lang.String nor type conversion possible: No type converter available
to convert from type: java.lang.String to the required type:
org.jboss.netty.channel.ChannelDownstreamHandler with value #myEncoder
	at
org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:341)
	at
org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:291)
	at
org.apache.camel.util.EndpointHelper.setProperties(EndpointHelper.java:225)
	at
org.apache.camel.component.netty.NettyConfiguration.parseURI(NettyConfiguration.java:125)
	at
org.apache.camel.component.netty.NettyComponent.createEndpoint(NettyComponent.java:49)
	at
org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)
	at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:432)
	... 18 more

--
View this message in context: http://camel.465427.n5.nabble.com/set-encoder-in-netty-exception-tp5130760p5130760.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message