You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by lmanchanda75 <lm...@gmail.com> on 2013/07/20 16:12:20 UTC
Camel HTTP4, not able to use httpContext endpoint option
Hi,
I want to set preemtive auth On of the servers, I am using http4 component,
going through various posts/camel documentation
(http://camel.apache.org/http4.html), I arrived at conclusion that I need to
set httpContext on the component/endpoint. I wrote a small piece of code to
create HttpContext and called the same in blueprint to set my bean in
registry as shown below:
public class HttpContextFactory {
Code-
public static HttpContext getObject(String httpHost,Integer httpPort) {
HttpContext httpContext = new BasicHttpContext() ;
BasicAuthCache authCache = new BasicAuthCache();
BasicScheme basicAuth = new BasicScheme();
authCache.put(new HttpHost(httpHost, httpPort), basicAuth);
httpContext.setAttribute(ClientContext.AUTH_CACHE, authCache);
return httpContext;
}
}
Blueprint -
<bean id="messageBrokerAuthContext"
class="manchanda.lalit.TryCxfSmooks.HttpContextFactory"
factory-method="getObject">
<argument value="172.168.1.100"/>
<argument value="1443"/>
</bean>
Usage -
http4://172.168.1.100?authUsername=user&authPassword=password&httpContext=messageBrokerAuthContext
During execution I get the following error-
Caused by: org.apache.camel.NoSuchBeanException: Found bean:
messageBrokerAuthCo
ntext in BlueprintContainer:
org.apache.aries.blueprint.container.BlueprintConta
inerImpl@c8f24 of type: org.apache.http.protocol.BasicHttpContext expected
type was: interface org.apache.http.protocol.HttpContext
This does not seem to be correct as it will never be possible to get
instance of HttpContext type it being an Interface.
How can I solve my problem of setting preemptive auth?
Regds
Lalit
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-HTTP4-not-able-to-use-httpContext-endpoint-option-tp5735937.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel HTTP4, not able to use httpContext endpoint option
Posted by lmanchanda75 <lm...@gmail.com>.
Hi,
Following is the complete stracktrace:
JBossFuse:karaf@root> org.apache.camel.ResolveEndpointFailedException:
Failed to
resolve endpoint:
http4://172.16.1.100?authPassword=password&authUsername=username&httpClient.connectionTimeout=4000&httpClient.soTimeout=16000&httpContext=m
essageBrokerAuthContext due to: Found bean: messageBrokerAuthContext in
BlueprintContainer:
org.apache.aries.blueprint.container.BlueprintContainerImpl@c603e7 o
f type: org.apache.http.protocol.BasicHttpContext expected type was:
interface org.apache.http.protocol.HttpContext
at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:488)
at
org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:436)
at
org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:292)
at
org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:329)
at
manchanda.lalit.TryCxfSmooks.IntegrationProcessor.sendHttpRequest(IntegrationProcessor.java:964)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:390)
at
org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:277)
at
org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:250)
at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:161)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.fabric.FabricTraceProcessor.process(FabricTraceProcessor.java:81)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334)
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:308)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
at
org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:135)
at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:63)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: org.apache.camel.NoSuchBeanException: Found bean:
messageBrokerAuthContext in BlueprintContainer:
org.apache.aries.blueprint.container.BlueprintConta
inerImpl@c603e7 of type: org.apache.http.protocol.BasicHttpContext expected
type was: interface org.apache.http.protocol.HttpContext
at
org.apache.camel.blueprint.BlueprintContainerRegistry.lookup(BlueprintContainerRegistry.java:66)
at
org.apache.camel.impl.CompositeRegistry.lookup(CompositeRegistry.java:51)
at
org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:62)
at
org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:119)
at
org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:139)
at
org.apache.camel.util.EndpointHelper.resolveReferenceParameter(EndpointHelper.java:320)
at
org.apache.camel.util.EndpointHelper.resolveReferenceParameter(EndpointHelper.java:302)
at
org.apache.camel.impl.DefaultComponent.resolveAndRemoveReferenceParameter(DefaultComponent.java:304)
at
org.apache.camel.impl.DefaultComponent.resolveAndRemoveReferenceParameter(DefaultComponent.java:283)
at
org.apache.camel.component.http4.HttpComponent.createEndpoint(HttpComponent.java:185)
at
org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:91)
at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:469)
... 52 more
Caused by: java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2999)
at
org.apache.camel.blueprint.BlueprintContainerRegistry.lookup(BlueprintContainerRegistry.java:62)
... 63 more
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-HTTP4-not-able-to-use-httpContext-endpoint-option-tp5735937p5735955.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel HTTP4, not able to use httpContext endpoint option
Posted by Willem jiang <wi...@gmail.com>.
Hi,
Can you show us more about the cause of the exception?
As the NoSuchBeanException should have the cause of the exception.
--
Willem Jiang
Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
On Saturday, July 20, 2013 at 10:12 PM, lmanchanda75 wrote:
> Hi,
>
> I want to set preemtive auth On of the servers, I am using http4 component,
> going through various posts/camel documentation
> (http://camel.apache.org/http4.html), I arrived at conclusion that I need to
> set httpContext on the component/endpoint. I wrote a small piece of code to
> create HttpContext and called the same in blueprint to set my bean in
> registry as shown below:
>
> public class HttpContextFactory {
>
> Code-
>
> public static HttpContext getObject(String httpHost,Integer httpPort) {
>
> HttpContext httpContext = new BasicHttpContext() ;
> BasicAuthCache authCache = new BasicAuthCache();
> BasicScheme basicAuth = new BasicScheme();
> authCache.put(new HttpHost(httpHost, httpPort), basicAuth);
>
> httpContext.setAttribute(ClientContext.AUTH_CACHE, authCache);
>
> return httpContext;
> }
>
>
>
> }
>
>
>
> Blueprint -
>
> <bean id="messageBrokerAuthContext"
> class="manchanda.lalit.TryCxfSmooks.HttpContextFactory"
> factory-method="getObject">
> <argument value="172.168.1.100"/>
> <argument value="1443"/>
> </bean>
>
>
>
> Usage -
>
> http4://172.168.1.100?authUsername=user&authPassword=password&httpContext=messageBrokerAuthContext
>
>
> During execution I get the following error-
>
>
> Caused by: org.apache.camel.NoSuchBeanException: Found bean:
> messageBrokerAuthCo
> ntext in BlueprintContainer:
> org.apache.aries.blueprint.container.BlueprintConta
> inerImpl@c8f24 of type: org.apache.http.protocol.BasicHttpContext expected
> type was: interface org.apache.http.protocol.HttpContext
>
>
>
> This does not seem to be correct as it will never be possible to get
> instance of HttpContext type it being an Interface.
>
> How can I solve my problem of setting preemptive auth?
>
> Regds
> Lalit
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-HTTP4-not-able-to-use-httpContext-endpoint-option-tp5735937.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).