Java 创建名为“cxf”的 bean 时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18908876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 12:13:28  来源:igfitidea点击:

Error creating bean with name 'cxf'

javaspringweb-servicesspring-mvc

提问by Suraj Menon

I am getting the following error on running my program

我在运行我的程序时遇到以下错误

Exception in thread "main" java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cxf' defined in class path resource [META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.bus.spring.SpringBus]: Constructor threw exception; nested exception is org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl.

my test.xml file is

我的 test.xml 文件是

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:cxf="http://cxf.apache.org/core"
    xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">


    <bean id="clientI"
        class="LI" />
    <bean id="clientL"
        class="LIn" />

        <cxf:bus>
        <cxf:outInterceptors>
            <ref bean="clientI" />
        </cxf:outInterceptors>
        <cxf:inInterceptors>
            <ref bean="clientL" />
        </cxf:inInterceptors>
    </cxf:bus>
</beans>

采纳答案by Ernestas Kardzys

Do you have cxf-bundle JAR in your classpath? Because this could be the problem.

你的类路径中有 cxf-bundle JAR 吗?因为这可能是问题所在。

You can get it from here: http://mvnrepository.com/artifact/org.apache.cxf/cxf-bundle/2.7.6(the latest version).

你可以从这里得到它:http: //mvnrepository.com/artifact/org.apache.cxf/cxf-bundle/2.7.6(最新版本)。

回答by gregoriomunoz

It could be possible because you are using an old version of neethi (maybe 2.X.X) and you should use version 3.0.2. Check your dependencies.

这可能是因为您使用的是旧版本的 neethi(可能是 2.XX),您应该使用 3.0.2 版。检查您的依赖项。

回答by bhaumikananda

For a resolution I had to add both cxf-bundle-xxx.jar and updated the neethi jar with the latest version.

为了解决这个问题,我必须同时添加 cxf-bundle-xxx.jar 并使用最新版本更新 neethi jar。

回答by Gio

If this happens on an EAR including an cxf-WebService deployed in WebSphere AS,

如果这种情况发生在 EAR 上,包括部署在 WebSphere AS 中的 cxf-WebService,

it may result from the class loader of the of the cxf-WebService-Module. Be shure that you set the class loader of the WebService-Module to PARENT_LAST

它可能来自 cxf-WebService-Module 的类加载器。确保将 WebService-Module 的类加载器设置为 PARENT_LAST