没有定义名为"cxf"的bean [英] No bean named 'cxf' is defined

查看:118
本文介绍了没有定义名为"cxf"的bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用tomcat 6.0.32,cxf 2.4.1设置一个简单的Rest Web应用程序.每当我发出任何呼叫时,我都会返回一个异常未定义名为'cxf'的bean",其中cxf是我的总线.

查看应用程序日志,可以看到cxf实例已创建并缓存.

================ APP LOG BEGIN =====================

910 DEBUG-创建单例bean'cxf'的共享实例

910 DEBUG-创建bean'cxf'的实例

1018调试-急速缓存bean'cxf'以允许解析潜在的循环引用

1031调试-返回急速缓存的单例bean'cxf'实例,该实例尚未完全初始化-循环引用的结果

1034调试-完成创建bean'cxf'实例

1035调试-返回单例bean'org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor'的缓存实例

1035调试-返回单例bean'org.apache.cxf.bus.spring.Jsr250BeanPostProcessor'的缓存实例

1035调试-返回单例bean'org.apache.cxf.bus.spring.BusExtensionPostProcessor'的缓存实例

1035调试-创建单例bean连接"的共享实例

1035调试-创建bean连接"实例

1035调试-急速缓存bean连接"以解决潜在的循环引用

1052调试-完成创建bean连接"实例

1052调试-创建单例bean'connectionService'的共享实例

1052调试-创建bean'connectionService'的实例

1053调试-急速缓存bean'connectionService'以允许解析潜在的循环引用

1053调试-返回单例bean'连接'的缓存实例

1053调试-返回单例bean'cxf'的缓存实例

1121调试-在名称为'connectionService'的bean上调用初始化方法'create'

1356 DEBUG-完成创建bean'connectionService'实例

名称为"lifecycleProcessor"的1384 DEBUG fecycleProcessor:使用默认的[org.springframework.context.support.DefaultLifecycleProcessor@45d1c3cd]

1385调试-返回单例bean'lifecycleProcessor'的缓存实例

1387 DEBUG-返回单例bean'cxf'的缓存实例

1387 DEBUG-返回单例bean'cxf'的缓存实例

1388 DEBUG-在名称为"connectionService"的bean上调用初始化方法"create"

1391调试-完成创建bean'connectionService'实例

1391调试-无法找到名称为'lifecycleProcessor'的LifecycleProcessor:使用默认的[org.springframework.context.support.DefaultLifecycleProcessor@2c3299f6]

1391调试-返回单例bean'lifecycleProcessor'的缓存实例

1391调试-将根WebApplicationContext作为ServletContext属性发布,名称为[org.springframework.web.context.WebApplicationContext.ROOT]

1391信息-根WebApplicationContext:初始化在1390毫秒内完成

================ APP LOG END =====================

但是,当一个请求进入时,它总是会失败,说找不到该bean.

====================== Tomcat(localhost)日志开始==================

信息:初始化Spring根WebApplicationContext

2011年7月14日上午8:57:03 org.apache.catalina.core.ApplicationContext日志

严重程度:StandardWrapper.Throwable

org.springframework.beans.factory.NoSuchBeanDefinitionException:未定义名为'cxf'的bean

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527)

at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1083)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)

at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:58)

at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:54)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)

at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)

at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)

at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)

at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)

at java.lang.Thread.run(Thread.java:662)

======================= Tomcat(localhost)日志结尾==================

我唯一想到的是,该bean插入了一个上下文,并且正在从另一个上下文中检索,但是无法对此进行验证或找到解决方法.任何帮助将不胜感激.

解决方案

从您的错误日志中,我假设您使用Spring,如果这样,则需要在Spring Context XML中添加以下行:

<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

希望这会有所帮助.

I am trying to setup a simple restful web application, using tomcat 6.0.32, cxf 2.4.1. Anytime I issue any call, I get back an exception "No bean named 'cxf' is defined", where cxf is my bus.

Looking at the application log, I can see the cxf instance is created, and cached.

================ APP LOG BEGIN======================

910 DEBUG - Creating shared instance of singleton bean 'cxf'

910 DEBUG - Creating instance of bean 'cxf'

1018 DEBUG - Eagerly caching bean 'cxf' to allow for resolving potential circular references

1031 DEBUG - Returning eagerly cached instance of singleton bean 'cxf' that is not fully initialized yet - a consequence of a circular reference

1034 DEBUG - Finished creating instance of bean 'cxf'

1035 DEBUG - Returning cached instance of singleton bean 'org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor'

1035 DEBUG - Returning cached instance of singleton bean 'org.apache.cxf.bus.spring.Jsr250BeanPostProcessor'

1035 DEBUG - Returning cached instance of singleton bean 'org.apache.cxf.bus.spring.BusExtensionPostProcessor'

1035 DEBUG - Creating shared instance of singleton bean 'connection'

1035 DEBUG - Creating instance of bean 'connection'

1035 DEBUG - Eagerly caching bean 'connection' to allow for resolving potential circular references

1052 DEBUG - Finished creating instance of bean 'connection'

1052 DEBUG - Creating shared instance of singleton bean 'connectionService'

1052 DEBUG - Creating instance of bean 'connectionService'

1053 DEBUG - Eagerly caching bean 'connectionService' to allow for resolving potential circular references

1053 DEBUG - Returning cached instance of singleton bean 'connection'

1053 DEBUG - Returning cached instance of singleton bean 'cxf'

1121 DEBUG - Invoking init method 'create' on bean with name 'connectionService'

1356 DEBUG - Finished creating instance of bean 'connectionService'

1384 DEBUG fecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@45d1c3cd]

1385 DEBUG - Returning cached instance of singleton bean 'lifecycleProcessor'

1387 DEBUG - Returning cached instance of singleton bean 'cxf'

1387 DEBUG - Returning cached instance of singleton bean 'cxf'

1388 DEBUG - Invoking init method 'create' on bean with name 'connectionService'

1391 DEBUG - Finished creating instance of bean 'connectionService'

1391 DEBUG - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@2c3299f6]

1391 DEBUG - Returning cached instance of singleton bean 'lifecycleProcessor'

1391 DEBUG - Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]

1391 INFO - Root WebApplicationContext: initialization completed in 1390 ms

================ APP LOG END======================

But when a request comes in, it always fails saying it can't find the bean.

===================== Tomcat (localhost) Log Begin ==================

INFO: Initializing Spring root WebApplicationContext

Jul 14, 2011 8:57:03 AM org.apache.catalina.core.ApplicationContext log

SEVERE: StandardWrapper.Throwable

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf' is defined

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527)

at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1083)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)

at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:58)

at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:54)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)

at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)

at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)

at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)

at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)

at java.lang.Thread.run(Thread.java:662)

===================== Tomcat (localhost) Log End ==================

The only thing I can think of is that the bean is inserted in one context, and is being retrieved from another, but can't validate this or find a way around it. Any help would be greatly appreciated.

解决方案

From your error log, I assume you use Spring, if so, you will need to add following lines to your Spring Context XML:

<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

Hope this helps.

这篇关于没有定义名为"cxf"的bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆