Reputation: 507
For testing an application I am creating SOAP messages. This works when run directly from Eclipse (Oxygen.1a) but after packaging as runnable jar (option: package required libraries into generated jar) I get the following error:
javax.xml.soap.SOAPException: Unable to create SAAJ meta-factoryProvider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
at javax.xml.soap.SAAJMetaFactory.getInstance(SAAJMetaFactory.java:94)
at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:138)
triggered by:
MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
So I understand that the MessageFactory uses a sun package
static private final String DEFAULT_META_FACTORY_CLASS =
"com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl";
But I am absolutly clueless as to why it is unable to find this class after packaging to a runnable JAR. Any hints or directions would be greatly apreciated.
Upvotes: 34
Views: 82807
Reputation: 11
for JDK greater 11, You can use the latest version of saal-impl given below:
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3.5</version>
</dependency>
Upvotes: 1
Reputation: 11
Use the latest "saaj-impl" maven dependency to resolve this issue.
com.sun.xml.messaging.saaj saaj-impl 3.0.3
As the "com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl" is not found, it is looking for default fallback package "com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl".
Upvotes: 0
Reputation: 1655
Yet another answer to get it working...
I am changing from Springboot2 to Version 3. I included a lib which uses some SOAP requests by/within an externally delivered Jar.
In order to solve the issue I have to include these two jars:
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.3</version>
</dependency>
Not having the jaxb-impl
artefact got me an Exception: java.lang.NoClassDefFoundError; message=com/sun/xml/bind/api/TypeReference
. I just looked up in what Jar the missing class is contained.
Also see https://stackoverflow.com/a/45429691/845117
Just this setting of pom versions does work for me. There are newer libs listed but they don't work but lead to Exceptions. Fair question by Houcem Berrayana in another comment why just this version does work but no greater major one...
Upvotes: 1
Reputation: 1
If you are using Weblogic, change the value of the parameter prefer-web-inf-classes
at weblogic.xml file.
It worked for me.
Upvotes: 0
Reputation: 43
After switching my jdk to 11,I had same problem. Uppgrading apache.cxf jar to 3.5.1 solved my problem.Was using 3.1.2 with jdk 1.8
Upvotes: 2
Reputation: 21
I'm using Java 11 and in addition to the
implementation group: 'com.sun.xml.messaging.saaj', name: 'saaj-impl', version: '1.5.2'
add
implementation group: 'javax.xml.soap', name: 'javax.xml.soap-api', version: '1.4.0'
but necessarily turn off implementation group: 'com.sun.xml.messaging.saaj', name: 'saaj-impl', version: '1.5.2'
Upvotes: 2
Reputation: 2490
The answers above (adding saaj-impl and saak-api) work for most projects, but I found out that if your project has a dependency on javax.xml webservices-api, you also need to remove that dependency in order to stop getting that error in Java 11.
Exemple of the dependency to remove in Maven :
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.0.1</version>
</dependency>
Upvotes: 0
Reputation: 11
I'm using Spring Boot 2.4.0 and Java 11. This is what worked for me:
implementation 'javax.xml.ws:jaxws-api:2.3.1'
implementation 'javax.jws:javax.jws-api:1.1'
implementation 'com.sun.xml.messaging.saaj:saaj-impl:1.5.1'
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2'
implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
Upvotes: 1
Reputation: 49
I have solved the problem by adding the following two dependencies
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3.5</version>
</dependency>
Upvotes: 1
Reputation: 1001
I just added the following dependency to my project:
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.1</version>
</dependency>
If you are using a version older than 1.5.1, you need to create the file META-INF/services/javax.xml.soap.SAAJMetaFactory
with the following line to provide the fully-qualified name of the SAAJ factory class and it worked:
com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl
The javax.xml.soap.saaj-api seems to be abandoned.
And it's very strange that a package named com.sun
is the one to work.
Anyway, it works.
Upvotes: 57