I’m new at Spring Boot. And currently, I have a problem with the running the project.
there is the error as
17:29:07.358 [main] ERROR o.s.boot.SpringApplication - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'passPolicyController' defined in file [D:InventadminbuildclassesjavamainkzbsbnbinventadmincontrollerPassPolicyController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'passPolicyServiceImpl' defined in file [D:InventadminbuildclassesjavamainkzbsbnbinventadminservicePassPolicyServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'soapServices' defined in class path resource [kz/bsbnb/invent/admin/config/SoapConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [kz.bsbnb.invent.admin.soap.SOAPServices]: Factory method 'soapServices' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:227) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1356) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1203) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) at kz.bsbnb.invent.admin.AdminApplication.main(AdminApplication.java:49) Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'passPolicyServiceImpl' defined in file [D:InventadminbuildclassesjavamainkzbsbnbinventadminservicePassPolicyServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'soapServices' defined in class path resource [kz/bsbnb/invent/admin/config/SoapConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [kz.bsbnb.invent.admin.soap.SOAPServices]: Factory method 'soapServices' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:227) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1356) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1203) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:884) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:788) ... 20 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'soapServices' defined in class path resource [kz/bsbnb/invent/admin/config/SoapConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [kz.bsbnb.invent.admin.soap.SOAPServices]: Factory method 'soapServices' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:635) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:884) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:788) ... 34 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [kz.bsbnb.invent.admin.soap.SOAPServices]: Factory method 'soapServices' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ... 48 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:149) at org.springframework.ws.support.DefaultStrategiesHelper.instantiateBean(DefaultStrategiesHelper.java:152) 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 org.springframework.ws.client.core.support.WebServiceGatewaySupport.<init>(WebServiceGatewaySupport.java:65) at kz.bsbnb.invent.admin.soap.SOAPServices.<init>(SOAPServices.java:35) at kz.bsbnb.invent.admin.config.SoapConfig.soapServices(SoapConfig.java:50) at kz.bsbnb.invent.admin.config.SoapConfig$$EnhancerBySpringCGLIB$$865ef7a.CGLIB$soapServices$2(<generated>) at kz.bsbnb.invent.admin.config.SoapConfig$$EnhancerBySpringCGLIB$$865ef7a$$FastClassBySpringCGLIB$$8a82b797.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) at kz.bsbnb.invent.admin.config.SoapConfig$$EnhancerBySpringCGLIB$$865ef7a.soapServices(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ... 49 common frames omitted Caused by: java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException at java.base/java.lang.Class.getDeclaredConstructors0(Native Method) at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3296) at java.base/java.lang.Class.getConstructor0(Class.java:3501) at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2711) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:139) ... 69 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.soap.SOAPException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 74 common frames omitted
and there is classes to consuming SOAP
Configuration class
@Configuration public class SoapConfig { @Bean public Jaxb2Marshaller marshaller () { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPaths("axis2.apache.org.xsd", "org.wso2.carbon.user.mgt.common.xsd", "org.wso2.carbon.um.ws.service.dao.xsd", "org.wso2.carbon.um.ws.service", "org.wso2.carbon.user.api.xsd", "org.wso2.carbon.user.core.xsd", "org.wso2.carbon.user.mgt.common.xsd", "org.wso2.carbon.identity.application.common.model.xsd", "org.wso2.carbon.identity.base.xsd", "org.wso2.carbon.idp.mgt.xsd", "org.wso2.carbon.idp.mgt"); return marshaller; } @Bean @Qualifier ("webServiceTemplate") public WebServiceTemplate webServiceTemplate () { WebServiceTemplate webServiceTemplate = new WebServiceTemplate(); webServiceTemplate.setMarshaller(marshaller()); webServiceTemplate.setUnmarshaller(marshaller()); webServiceTemplate.setMessageSender(messageSender()); return webServiceTemplate; } @Bean public SOAPServices soapServices (Jaxb2Marshaller marshaller) { SOAPServices soapServices = new SOAPServices(); soapServices.setMarshaller(marshaller); soapServices.setUnmarshaller(marshaller); soapServices.setMessageSender(messageSender()); return soapServices; } private HttpUrlConnectionMessageSender messageSender () { return new HttpUrlConnectionMessageSender() { @Override protected void prepareConnection (HttpURLConnection connection) throws IOException { String credentials = String.format("%s:%s", "admin", "admin"); String encodedAuthorization = Base64.getEncoder().encodeToString(credentials.getBytes()); connection.setRequestProperty("Authorization", String.format("Basic %s", encodedAuthorization)); super.prepareConnection(connection); } }; } }
Service class to generate methods
public class SOAPServices extends WebServiceGatewaySupport { private final ObjectFactory factory = new ObjectFactory(); private final org.wso2.carbon.um.ws.service.ObjectFactory objectFactory = new org.wso2.carbon.um.ws.service.ObjectFactory(); private final org.wso2.carbon.idp.mgt.ObjectFactory idpFactory = new org.wso2.carbon.idp.mgt.ObjectFactory(); private final org.wso2.carbon.identity.application.common.model.xsd.ObjectFactory idPropFactory = new org.wso2.carbon.identity.application.common.model.xsd.ObjectFactory(); @Autowired private WsoConstant wsoConstant; @Autowired @Qualifier ("webServiceTemplate") private WebServiceTemplate webServiceTemplate; public List<String> getAllUsername () { ListUsers request = factory.createListUsers(); request.setFilter(factory.createListUsersFilter("*")); request.setLimit(100); ListUsersResponse listUsersResponse = (ListUsersResponse) webServiceTemplate.marshalSendAndReceive(wsoConstant.getAdminEndpoint(), request); return listUsersResponse.getReturn(); } }
PassPolicyService Service class
@Service public class PassPolicyServiceImpl implements PassPolicyService { private final SOAPServices soapServices; public PassPolicyServiceImpl (SOAPServices soapServices) {this.soapServices = soapServices;} @Override public IdpPropPassDto getPassPolicy () throws InventException { IdpPropPassDto idpPropPassDto = new IdpPropPassDto(); soapServices.getIdpResidentValues().getIdpProperties().forEach((key, val) -> { if (key.equals("passwordPolicy.min.length")) { idpPropPassDto.setMinLength(Integer.parseInt(val)); } if (key.equals("passwordPolicy.max.length")) { idpPropPassDto.setMaxLength(Integer.parseInt(val)); } if (key.equals("passwordPolicy.errorMsg")) { idpPropPassDto.setErrorMsg(val); } if (key.equals("passwordPolicy.pattern")) { idpPropPassDto.setPassPattern(val); } }); return idpPropPassDto; } @Override public Boolean updatePassPolicy (IdpPropPassDto idpPropPassDto) throws InventException { WsoPassProp passProp = soapServices.getIdpResidentValues(); passProp.getIdpProperties().clear(); passProp.getIdpProperties().put("passwordPolicy.min.length",idpPropPassDto.getMinLength().toString()); passProp.getIdpProperties().put("passwordPolicy.max.length",idpPropPassDto.getMaxLength().toString()); passProp.getIdpProperties().put("passwordPolicy.errorMsg",idpPropPassDto.getErrorMsg()); passProp.getIdpProperties().put("passwordPolicy.pattern", idpPropPassDto.getPassPattern()); return soapServices.updateResidentIdP(passProp); } }
I thought it’s happening because tried to @Autowire service class inside Service class. Then I tried to look up how to consume SOAP in https://spring.io/guides/gs/consuming-web-service/. And it didn’t help to me. I can’t get what is the promlem here. Could you help my? Thank you in advance
Advertisement
Answer
Compiler can not find class javax/xml/soap/SOAPException. I think this link can help you to solve problem java.lang.NoClassDefFoundError : javax/xml/soap/SOAPException