I have a JAX-RS resource, using Jersey, that provides a resource InstallOrder. When there is a POST Request for this resource it shall make a SOAP request and send it to yet another web service. I'm using the jakarta.xml.soap-api 1.4.2 library for the creation and sending of the SOAPMessage.
Before creating the SOAPMessage I'm getting a NullPointerException because SOAPConnectionFactory.newInstance() returns null. The code snippet looks like this:
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance()
SOAPConnection connection = scf.createConnection();
The scf is unexpectedly null here. I'm using the exact same code in another SOAP web service with the same library and it works like a charm. I don't get where the problem is.
I had the same problem and in my case I solved it by explicitly adding this to my POM file.
If you're not using Maven then this won't help directly, however it might help to know that behind the scenes the SOAPConnectionFactory uses com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory to implement SOAP. At least this is true for javax.xml.soap-api 1.4.0.