Unable to create SOAP connection factory: Provider com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory not found
Asked Answered
E

3

8

I am currently developping a Java server app that connect to another server with SOAP, retrieve some data and store it into a DB. I work on Eclipse Photon, Maven project.

My Soap client worked perfectly fine until now. For my db storage functions, I needed the JDBC SQL Server driver. But Eclipse told me that driver was compiled with a more recent version of Java.

I was on Java 8, I updated to Java 10 and now the driver works fine BUT my SOAP client doesn't work anymore ! Eclipse doesn't recognize the import javax.xml.soap I use for my Soap.

So I put into my pom.xml some dependencies for it like :

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.soap/javax.xml.soap-api -->
<dependency>
    <groupId>javax.xml.soap</groupId>
    <artifactId>javax.xml.soap-api</artifactId>
    <version>1.4.0</version>
</dependency>

The import of javax seemed to be recognized again by Eclipse so I compiled my project with Tomcar to launch it and after trying my Soap client it gives me the following error :

java.lang.Exception: Unable to create SOAP connection factory: Provider com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory not found

Elda answered 12/11, 2018 at 10:6 Comment(0)
B
18

Adding this dependency to my POM fixed the issue:

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

It also fixes this error: javax.xml.soap.SOAPException: Unable to create message factory for SOAP: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found

Betroth answered 5/2, 2019 at 16:58 Comment(0)
F
1

I had this same scenario, here's how I fixed it:

I downloaded the saaj-impl jar and the mimepull dependency https://jar-download.com/artifacts/com.sun.xml.messaging.saaj/saaj-impl/1.3.6/source-code

I imported these two jars into intelliJ as a dependency via File -> Project Structure -> Modules -> Dependencies

Then I added the maven dependencies into pom.xml:

<!-- saaj-impl-1.3.16.jar maven dependency -->
<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>LATEST</version>
    <systemPath>${project.basedir}/(from project folder to jar file).../saaj-impl- 
    1.3.16.jar</systemPath>
    <scope>system</scope>
</dependency>

<!-- mimepull-1.7.jar maven dependency -->
<dependency>
    <groupId>org.jvnet.mimepull</groupId>
    <artifactId>mimepull</artifactId>
    <version>LATEST</version>
    <systemPath>${project.basedir}/(from project folder to jar file).../mimepull- 
    1.7.jar</systemPath>
    <scope>system</scope>
</dependency>

After closing the project and reopening, I stopped getting the missing soapconnectionfactory class error!

Freemasonry answered 14/11, 2018 at 14:55 Comment(2)
Why did you download the JARs? You could simply add normal Maven dependencies and let Maven download / manage them for you.Betroth
sometimes you have to download the jars. I think people play "small headed" ("if it's not like my usage, it does not exist") and ignore a plethora of cases where downloading and rebuilding is hilariously impossible. Just yesterday I had to build, package and repackage a maven project into jar for a certain UK internet infrastructure entity. If the kinda people who came up with the internet think jars are a good idea, who are we to argue!Coraleecoralie
E
0

Adding my answer from a MuleSoft perspective, because Google brought me here. To stop the runtime error Unable to create SOAP connection factory: Provider com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory not found when calling SOAPConnectionFactory.newInstance() in Java code, I had to add saaj-impl as a shared library in the POM file's mule-maven-plugin configuration:

<plugin>
    <groupId>org.mule.tools.maven</groupId>
    <artifactId>mule-maven-plugin</artifactId>
    <version>${mule.maven.plugin.version}</version>
    <extensions>true</extensions>
    <configuration>
        <sharedLibraries>
            <sharedLibrary>
                <groupId>com.sun.xml.messaging.saaj</groupId>
                <artifactId>saaj-impl</artifactId>
            </sharedLibrary>
        </sharedLibraries>
    </configuration>

You still have to also define saaj-impl as a dependency in the POM file as well:

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

The reason for this is that (from the MuleSoft documentation) all dependencies (JAR files, for example) declared in the application’s pom.xml file are visible to the application's class loader but not visible to the class loader of each connector used in the application. The Mule runtime engine class-loading mechanism isolates each connector to prevent it from accessing classes from other connectors. If a connector's class loader needs access to an application dependency, declare this dependency as a shared library.

Ectoblast answered 24/9, 2024 at 1:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.