I'm trying to publish to a MQTT topic thanks to the appropriate Apache Camel MQTT component.
So in my spring context XML I have the following:
<camel:to uri="mqtt:test?host=ssl://myhost:8883&publishTopicName=test&userName=test&password=test"/>
But I'm getting the following error at startup :
Failed to create Producer for endpoint: Endpoint[mqtt:test?host=ssl://myhost:8883&publishTopicName=test&userName=test&password=test]. Reason: java.lang.NullPointerException
Everything is working fine when not using ssl, the following configuration (regular tcp instead of ssl) is working well :
<camel:to uri="mqtt:test?host=tcp://myhost:1883&publishTopicName=test&userName=test&password=test"/>
I've added the javax.net.ssl.trustStore JVM property pointing to my certificates store but without any effect.
Does someone already met this issue ? Is there something to specifically add in the spring DSL configuration file when using the camel mqtt component with ssl ?
EDIT : The stacktrace of the NPE :
Caused by: java.lang.NullPointerException at org.fusesource.hawtdispatch.transport.SslTransport.connecting(SslTransport.java:194) at org.fusesource.mqtt.client.CallbackConnection.createTransport(CallbackConnection.java:285) at org.fusesource.mqtt.client.CallbackConnection.connect(CallbackConnection.java:138) at org.apache.camel.component.mqtt.MQTTEndpoint.connect(MQTTEndpoint.java:305) at org.apache.camel.component.mqtt.MQTTProducer.doStart(MQTTProducer.java:38) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3219) at org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1209) at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1170) at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:442) ... 33 more
javax.net.debug=ssl
to see in the log what's actually going on with SSL communication. There could be bunch of reasons behind the scene and depends on SSL requirements to hosts. i.e. server certificate, client certificate, private keys in case of two-way SSL and so on... – Vadim