8

I'm working on an application that consumes a web service using SOAP requests.

Sometimes I get this error:

filters.LoggerFilter:92 - org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.Error: javax.xml.soap.SOAPException: Unable to create SAAJ meta-factoryProvider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found

The weird part is that I get this error randomly, but I can't seem to figure out the cause.

I even added a new dependency, but it doesn't seem to correct the issue:

    <dependency>
        <groupId>com.sun.xml.messaging.saaj</groupId>
        <artifactId>saaj-impl</artifactId>
        <version>1.3</version>
    </dependency>
guidev
  • 2,695
  • 2
  • 23
  • 44

6 Answers6

14

I just had the same problem while using Java 11 to create an application that consumes SOAP-requests.

I added the new dependency and it worked fine for me.

<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.5.1</version>
</dependency>
Amelie St.
  • 141
  • 1
  • 3
  • I needed to add -Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl to the java command in Java 11 – Narayan Feb 19 '21 at 01:03
5

For me, I was using Java 13 and the following worked for me(add these in the pom.xml)

    <dependency>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>webservices-rt</artifactId>
        <version>2.4.4</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>webservices-api</artifactId>
        <version>2.4.4</version>
    </dependency>
Sam ツ
  • 583
  • 2
  • 7
  • 17
  • 1
    Tried many things but this worked for java11 – Ashish Kumar Mondal Dec 03 '21 at 22:48
  • Thank you very much! You saved my day :) I just want to add that this config works for Java 13. But don't try to update versions of these packages! Just copy as it is with versions 2.4.4. Because newer packages not working for Java 13. – Stargazer Jul 27 '22 at 13:12
2

For those who face this issue in intellij IDEA using Spring Boot under Java SDK 9+, you have to include explicitly --add-modules java.se.ee in VM parameters (edit configurations -> VM options). This answer may help to resolve other importing issues related to new Java Modules

rahimli
  • 1,373
  • 11
  • 25
1

I had the same problem. For me, adding saaj-impl was not enough to get rid of the exception

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

I had to also add saaj-api which fixed it finally:

<dependency>
    <groupId>javax.xml.soap</groupId>
    <artifactId>saaj-api</artifactId>
    <version>1.3.5</version>
</dependency>

Since I realised that my application was using saaj-api 1.3.4 after checking with command, upgrading to 1.3.5 helped

mvn dependency:tree -Dverbose

bahadir_g
  • 215
  • 2
  • 16
0

Change your project sdk as Java 1.8

If you are using import javax.xml.ws library it could be confusing com.sun.xml.messaging.saaj dependency in Java 11. Clearing saaj dependency then using Java8 may be a solution in this issue

ebey
  • 93
  • 8
  • Can you please elaborate why this should solve the problem? – Genry Jun 08 '21 at 12:51
  • If you are using import javax.xml.ws library it could be confusing com.sun.xml.messaging.saaj dependency in Java 11. Clearing saaj dependency then using Java8 may be a solution in this issue – ebey Jun 09 '21 at 15:04
  • can you please add it as part of your answer? – Genry Jun 14 '21 at 08:54
  • I had the same problem with java 8, and is packaging my application as war and deploying to Tomcat 9. remove, if added, saaj-impl, saaj-api and jaxws-api from pom. and add cxf-rt-frontend-jaxrs depedency. this should fix your problem. try doing pom-> maven-> reload project to be sure that jars are refreshed. – Abhinash Jha Sep 25 '22 at 14:18
0

With open JDK 17 and spring boot 3.0.1, I was getting the same issue. It got resolved by adding these dependencies in pom.xml

<dependency>
       <groupId>org.glassfish.metro</groupId>
       <artifactId>webservices-rt</artifactId>
       <version>2.4.4</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>webservices-api</artifactId>
        <version>2.4.4</version>
    </dependency>
Parul
  • 341
  • 3
  • 2