Search code examples
springweb-servicescxf

Configuration issue: Failed to import bean definitions from URL location


I am trying to use apache cxf to generate webservice in my Spring project. Everything goes well as I can see generated wsdl file and other files but I get org.springframework.beans.factory.parsing.BeanDefinitionParsingException.I am not using spring anywhere. So I think that whether generated wsdl is not correct one.

Here are few logs:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/cxf/cxf-extension-soap.xml]
Offending resource: ServletContext resource [/WEB-INF/cxf-beans.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/cxf/cxf-extension-soap.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] cannot be opened because it does not exist
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:256)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:207)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:192)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)

Solution

  • cxf-beans.xml is spring configuration metadata which creates bean, manages life cycle and dependenices. Since in your web.xml you have added the contextloader with context param giving location of the cxf-bean.xml, you have switched on spring container on top of which cxf runs.

    Coming back to your issue, it seems like you don't have all your dependecies(jars) for your cxf soap service. Since from cxf version 2.3 cxf.xml internally resolves all the required cxf-extension-*.xml and since you are using soap, I believe its searching for cxf-extension-soap.xml which is part of cxf-rt-bindings-soap.jar. Make sure all the cxf dependent jars are loaded