lordzeu
lordzeu

Reputation: 31

SOAPConnectionFactory.newInstance() returns null in JAX-RS resource

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.

Upvotes: 0

Views: 671

Answers (1)

DAB
DAB

Reputation: 1873

I had the same problem and in my case I solved it by explicitly adding this to my POM file.

<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>2.0.1</version>
</dependency>

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.

Upvotes: 0

Related Questions