You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Willem Jiang (JIRA)" <ji...@apache.org> on 2009/05/20 06:59:50 UTC

[jira] Resolved: (CAMEL-1628) Restlet component fails with NPE if used in combination with dynamic recipients (recipientList())

     [ https://issues.apache.org/activemq/browse/CAMEL-1628?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang resolved CAMEL-1628.
---------------------------------

    Resolution: Won't Fix

This issue is fixed in the CAMEL-1516.
Please check out the latest released Camel 1.6.1 or coming out Camel 2.0-m2 for verifcation.

> Restlet component fails with NPE if used in combination with dynamic recipients (recipientList())
> -------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1628
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1628
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.0-M1
>         Environment: WinXP SP3, Java 5  (suspect not relevant to this problem)
> Restlet 1.1.1 (suspect not relevant to this problem)
>            Reporter: Dan Haywood
>            Assignee: Willem Jiang
>
> see also: http://www.nabble.com/How-extract-message-body-and-use-later-on-in-route-for-endpoint--td23612034.html
> I've got:
> private static final String HOST_URI = "http://localhost:7070";
> from("direct:getEmployee")
> .to("restlet:" + HOST_URI + "/services")
> .process(new Processor() {
>     public void process(Exchange exchange) throws Exception {
>         String resourcePath = ... xpath to obtain the resource path from exchange.getIn().getBody()
>         message.setBody(resourcePath);
>         exchange.setOut(message);
>     }
> }).recipientList(new ExpressionAdapter(){
>     public Object evaluate(Exchange exchange) {
>         return "restlet:" + HOST_URI + exchange.getIn().getBody();
>     }
> });
> The first restlet call succeeds, returning an XHTML entity.  The processor then extracts a resource from an <a href>
> The ExpressionAdapter dynamically constructs a new Uri to invoke via Restlet.  However, this second restlet call fails, with a nullpointerexception.  It seems that the org.restlet.Restlet is instantiated with the default constructor.  For the first successful call the Restlet#init() method is called, so its context is setup correctly.  But for the second restlet call #init() doesn't seem to get called.
> This ultimately triggers the NPE in com.neolios.restlet.http.HttpConverter#addAdditionalHeaders, trying to get a Logger from this context object, but it is passed in from RestletComponent which I imagine wraps the Restlet.
> My guess is that it is the dynamic creation of the recipientList is what's ultimately responsible for this failure to call #init()?
> This is Camel 2.0-M1 against Restlet 1.1.1.
> ----
> Some stacktraces:
> 1. first time through:
> Component(Restlet).setContext(Context) line: 228	
> ComponentHelper.<init>(Component) line: 64	
> Engine.createHelper(Component) line: 380	
> Engine.createHelper(Component) line: 105	
> Component.<init>() line: 177	
> RestletComponent.<init>() line: 46	
> NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]	
> NativeConstructorAccessorImpl.newInstance(Object[]) line: 39	
> DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27	
> Constructor<T>.newInstance(Object...) line: 494	
> Class<T>.newInstance0() line: 350 [local variables unavailable]	
> Class<T>.newInstance() line: 303 [local variables unavailable]	
> ObjectHelper.newInstance(Class<T>) line: 797	
> ReflectionInjector.newInstance(Class<T>) line: 32	
> DefaultComponentResolver.resolveComponent(String, CamelContext) line: 72	
> DefaultCamelContext.getComponent(String) line: 201	
> DefaultCamelContext.getEndpoint(String) line: 354	
> CamelContextHelper.getMandatoryEndpoint(CamelContext, String) line: 52	
> RouteDefinition.resolveEndpoint(String) line: 133	
> DefaultRouteContext.resolveEndpoint(String) line: 103	
> DefaultRouteContext.resolveEndpoint(String, String) line: 109	
> ToDefinition(SendDefinition<Type>).resolveEndpoint(RouteContext) line: 57	
> ToDefinition(SendDefinition<Type>).createProcessor(RouteContext) line: 51	
> -vs-
> 2. second time through, is constructed, but no setContext was called:
> Client(Restlet).<init>(Context) line: 79	
> Client(Connector).<init>(Context, List<Protocol>) line: 83	
> Client.<init>(Context, List<Protocol>, String) line: 82	
> Client.<init>(Context, Protocol) line: 101	
> Client.<init>(Protocol) line: 121	
> Client.<init>(String) line: 131	
> RestletProducer.<init>(RestletEndpoint) line: 38	
> RestletEndpoint.createProducer() line: 73	
> ProducerCache.getProducer(Endpoint) line: 52	
> RecipientList.sendToRecipientList(Exchange, Object) line: 74	
> RecipientList.process(Exchange) line: 62	
> InstrumentationProcessor.process(Exchange, AsyncCallback) line: 80	
> StreamCachingInterceptor.proceed(Exchange, AsyncCallback) line: 88	
> StreamCachingInterceptor.process(Exchange, AsyncCallback) line: 83	
> DeadLetterChannel.process(Exchange, AsyncCallback, DeadLetterChannel$RedeliveryData) line: 195	
> DeadLetterChannel.process(Exchange, AsyncCallback) line: 130	
> Pipeline.process(Exchange, Exchange, AsyncCallback, Iterator<Processor>, AsyncProcessor) line: 115	
> Pipeline.process(Exchange, AsyncCallback) line: 89	
> InstrumentationProcessor.process(Exchange, AsyncCallback) line: 68	
> StreamCachingInterceptor.proceed(Exchange, AsyncCallback) line: 88	
> StreamCachingInterceptor.process(Exchange, AsyncCallback) line: 83	
> UnitOfWorkProcessor.process(Exchange, AsyncCallback) line: 52	
> AsyncProcessorHelper.process(AsyncProcessor, Exchange) line: 41	
> UnitOfWorkProcessor(DelegateAsyncProcessor).process(Exchange) line: 65	
> DirectProducer.process(Exchange) line: 47	
> ProducerCache.sendExchange(Endpoint, Producer, Processor, Exchange) line: 151	
> ProducerCache.send(Endpoint, ExchangePattern, Processor) line: 136	
> DefaultProducerTemplate.send(Endpoint, ExchangePattern, Processor) line: 99	
> DefaultProducerTemplate.sendBody(Endpoint, ExchangePattern, Object) line: 103

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.