You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ckiran <ki...@ymail.com> on 2012/02/20 18:43:20 UTC
HTTPS Usage
Hi,
I am trying to use camel HTTP4 component with SSL. The certificates are set
up on client and server for 2 way SSL and followingis the client side code.
CamelContext camelCtx = new DefaultCamelContext();
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("C:\\work\\client.jks");
ksp.setPassword("client");
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyStore(ksp);
kmp.setKeyPassword("client");
SSLContextParameters scp = new SSLContextParameters();
scp.setKeyManagers(kmp);
HttpComponent httpComponent = camelCtx.getComponent("https4",
HttpComponent.class);
httpComponent.setSslContextParameters(scp);
try {
Exchange exchange =
camelCtx.createProducerTemplate().send("https4://localhost:8443", new
Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(Exchange.HTTP_METHOD, "GET");
}
});
System.out.println("Object is " + exchange);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Complete!!!!!!");
}
I am always getting a null pointer exception on teh line I create the
exchange and send. Any idea what is going wrong here. This is a simple HTTPS
service which returns some xml data. Outside of Camel I tested this service
from browser and it works fine.
Can someone point out whats wrong in this code?
Regards
Kiran
--
View this message in context: http://camel.465427.n5.nabble.com/HTTPS-Usage-tp5499772p5499772.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: HTTPS Usage
Posted by Taariq Levack <ta...@gmail.com>.
Hi
You didn't start the camel context, so the component is not started, so the
connection manager is not initialised either.
Please try camelCtx.start();
Taariq
On Mon, Feb 20, 2012 at 8:33 PM, ckiran <ki...@ymail.com> wrote:
> This is he exact exceptionI get when I run the code.
>
> org.apache.camel.ResolveEndpointFailedException: Failed to resolve
> endpoint:
> https4://localhost:8443 due to: null
> at
>
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:443)
> at
>
> org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:423)
> at
>
> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:95)
> at CamelHttpsClient.main(CamelHttpsClient.java:31)
> Caused by: java.lang.NullPointerException
> at
>
> org.apache.camel.component.http4.HttpComponent.registerPort(HttpComponent.java:251)
> at
>
> org.apache.camel.component.http4.HttpComponent.createEndpoint(HttpComponent.java:219)
> at
>
> org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)
> at
>
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:425)
> ... 3 more
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/HTTPS-Usage-tp5499772p5499879.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: HTTPS Usage
Posted by ckiran <ki...@ymail.com>.
This is he exact exceptionI get when I run the code.
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint:
https4://localhost:8443 due to: null
at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:443)
at
org.apache.camel.impl.DefaultProducerTemplate.resolveMandatoryEndpoint(DefaultProducerTemplate.java:423)
at
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:95)
at CamelHttpsClient.main(CamelHttpsClient.java:31)
Caused by: java.lang.NullPointerException
at
org.apache.camel.component.http4.HttpComponent.registerPort(HttpComponent.java:251)
at
org.apache.camel.component.http4.HttpComponent.createEndpoint(HttpComponent.java:219)
at
org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)
at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:425)
... 3 more
--
View this message in context: http://camel.465427.n5.nabble.com/HTTPS-Usage-tp5499772p5499879.html
Sent from the Camel - Users mailing list archive at Nabble.com.