Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
Asked Answered
L

4

9

I am trying to upgrade my project to java 15. While trying to launch the server I'm getting error during bean creation.

util-context.xml:

<beans:bean id="dummyAdaptor" class="org.dummy.adaptor.DummyAdaptor"></beans:bean>
<beans:bean id = "soapRequestProcessorWithAction" class="org.dummy.adaptor.request.processor.SOAPRequestProcessorWithAction" />
<beans:bean id="soapWebServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
   <beans:property name="marshaller" ref="marshaller" />
   <beans:property name="unmarshaller" ref="unmarshaller" />
</beans:bean>

DummyAdaptor.java:

private SOAPRequestProcessorWithAction<CTRMProcessRequest, CTRMProcessResponse> soapRequestProcessorWithAction;

SOAPRequestProcessorWithAction.java:

@Autowired
@Qualifier("soapWebServiceTemplate")
private WebServiceTemplate webServiceTemplate;

errors:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dummyAdaptor': Unsatisfied dependency expressed through field 'soapRequestProcessorWithAction'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'soapRequestProcessorWithAction': Unsatisfied dependency expressed through field 'webServiceTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'soapWebServiceTemplate' defined in class path resource [util-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.client.core.WebServiceTemplate]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Invocation of init method failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create SAAJ MessageFactory: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found; nested exception is javax.xml.soap.SOAPException: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1415)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        ...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'soapRequestProcessorWithAction': Unsatisfied dependency expressed through field 'webServiceTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'soapWebServiceTemplate' defined in class path resource [util-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.client.core.WebServiceTemplate]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Invocation of init method failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create SAAJ MessageFactory: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found; nested exception is javax.xml.soap.SOAPException: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1415)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
        ... 60 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'soapWebServiceTemplate' defined in class path resource [util-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.client.core.WebServiceTemplate]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Invocation of init method failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create SAAJ MessageFactory: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found; nested exception is javax.xml.soap.SOAPException: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1318)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1216)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:571)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
        ... 73 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.client.core.WebServiceTemplate]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Invocation of init method failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create SAAJ MessageFactory: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found; nested exception is javax.xml.soap.SOAPException: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:225)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1310)
        ... 84 more
Caused by: org.springframework.beans.factory.BeanCreationException: Invocation of init method failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create SAAJ MessageFactory: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found; nested exception is javax.xml.soap.SOAPException: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
        at org.springframework.ws.support.DefaultStrategiesHelper.instantiateBean(DefaultStrategiesHelper.java:188)
        at org.springframework.ws.support.DefaultStrategiesHelper.getDefaultStrategies(DefaultStrategiesHelper.java:134)
        at org.springframework.ws.support.DefaultStrategiesHelper.getDefaultStrategy(DefaultStrategiesHelper.java:219)
        at org.springframework.ws.support.DefaultStrategiesHelper.getDefaultStrategy(DefaultStrategiesHelper.java:203)
        at org.springframework.ws.client.core.WebServiceTemplate.initMessageFactory(WebServiceTemplate.java:353)
        at org.springframework.ws.client.core.WebServiceTemplate.initDefaultStrategies(WebServiceTemplate.java:342)
        at org.springframework.ws.client.core.WebServiceTemplate.<init>(WebServiceTemplate.java:130)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:212)
        ... 86 more
Caused by: org.springframework.ws.soap.SoapMessageCreationException: Could not create SAAJ MessageFactory: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found; nested exception is javax.xml.soap.SOAPException: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
        at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.afterPropertiesSet(SaajSoapMessageFactory.java:165)
        at org.springframework.ws.support.DefaultStrategiesHelper.instantiateBean(DefaultStrategiesHelper.java:185)
        ... 98 more
**Caused by: javax.xml.soap.SOAPException: Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found**
        at javax.xml.soap.SAAJMetaFactory.getInstance(SAAJMetaFactory.java:112)
        at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:150)
        at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.afterPropertiesSet(SaajSoapMessageFactory.java:143)
        ... 99 more

    
    
    

As per the solutions I found online i added below mentioned dependecy.

compile group: 'com.sun.xml.messaging.saaj', name: 'saaj-impl', version: '2.0.0'

However in the saaj-impl.jar the SAAJMetaFactoryImpl.class in present at location com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl instead of com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl.

Livengood answered 19/1, 2021 at 12:56 Comment(0)
K
16

Probably you resolved the problem by now, but for future reference:

  • com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl is the name of the SAAJMetaFactory distributed in JREs up to Java SE 8. It is the default factory used whenever no implementation of javax.xml.soap.SAAJMetaFactory is found on the classpath. In my opinion this is a bug: an external jakarta.xml.soap-api jar, shouldn't fall back to an internal JRE implementation of the API, but throw an exception stating that no implementation was found.
  • you added saaj-impl-2.0.0 to the classpath. However this is part of the new Jakarta EE 9 standard and uses jakarta instead of javax as prefix (i.e. it contains an implementation of jakarta.xml.soap.SAAJMetaFactory). Switch to version 1.5.2 and everything should work.
Klaus answered 2/2, 2021 at 9:2 Comment(2)
adding xml <dependency> <groupId>com.sun.xml.messaging.saaj</groupId> <artifactId>saaj-impl</artifactId> <version>1.5.3</version> </dependency> solved it for me. I didn't need the System.setProperty commands other's suggested.Huberty
same for me, just added the same as @Huberty and it worksOblast
P
4

In my case, I was not using the new Jakarta EE standard. I set these two properties:

System.setProperty("javax.xml.soap.SAAJMetaFactory","com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");
System.setProperty("javax.xml.soap.MetaFactory","com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");

Reason for both is that my local maven build + tomcat warned on MetaFactory to use SAAJMetaFactory instead but the server I deployed to only seems to use MetaFactory so I set both.

Punitive answered 2/2, 2022 at 0:22 Comment(0)
R
1

I spent some time struggling with this issue as well, and in my case I had to set the system property in my code:

System.setProperty("jakarta.xml.soap.SAAJMetaFactory", "com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");
Rectify answered 24/6, 2021 at 7:23 Comment(0)
S
1

I used the version 3.0.0 of com.sun.xml.messaging.saaj:saaj-impl at first and faced the same problem.

For me the issue was fixed when I switched the version to 1.4.0 -->

implementation("com.sun.xml.messaging.saaj:saaj-impl:1.4.0")

Shu answered 27/10, 2022 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.