org.apache.cxf.service.factory.ServiceConstructionException: Could not resolve a binding for null:
�����openfire�Ļ�ṹ��ʵ�ʼ���, ������CXF��������������ܾ���
��Thread.currentThread().getContextClassLoader()
�� 2009-12-16 18:39, Willem Jiang �:
梁文龙-2 wrote:
>
> 关于
>
> org.apache.cxf.service.factory.ServiceConstructionException: Could not
> resolve a binding for null:
>
> 不清楚openfire的基础结构和实际技术, 但是引发CXF的这个错误的最大可能就在
> 于Thread.currentThread().getContextClassLoader()
>
>
> 于 2009-12-16 18:39, Willem Jiang 写道:
>> CXF 支持Servlet Transport, 你在openfire容器中部署的时候出现了什么问题?
>> 是不是因为Spring 版本冲突出现的问题。
>>
>> 单从你给的Stack trace 来看可能是bus创建过程中出现的问题。
>> 你可以好好研究一下CXF bus 创建部分的代码。
>>
>> 还有你如果还有有关CXF的问题,建议你发到cxf...@googlegroups.com, 这样讨论
>> 范围会大一些,
>> 而且别人也能从你的讨论中获益。
>>
>> 姜宁
>>
>> 陈世伟 wrote:
>>
>>> 姜宁:
>>> 你好
>>> 最近在一个项目上使用CXF,发现有很多问题百思不得其解,在网上也查了很
>>> 多资料 始终没有解决。希望你能指点一二,打扰见谅。
>>> 我的项目里有个设计方案 就是要把openfire 和webservice整合在一起,通过
>>> 发布接口 让第三方访问openfire里面的数据。目前我的实现方案是通过写
>>> openfire插件来实现webservice的功能。在实现的过程中发现整合SPRING的CXF 在
>>> openfire自带的JETTY容器中 会出现很多问题,于是就想到将spring与CXF分离。
>>> 起初第一步,我extends CXFNonSpringServlet 这个类并按照官方的例子
>>> OVERRIDE了 loadBus 这个方法,代码如下:
>>> public void loadBus(ServletConfig servletConfig) throws ServletException
>>> {
>>>
>>> // You can als use the simple frontend API to do this
>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>
>>> factroy.setBus(bus);
>>> factroy.setServiceClass(HelloWorld.class);
>>> factroy.setAddress("/HelloWorld");
>>> factroy.setServiceBean(helloworldImpl);
>>> factroy.create();
>>> }
>>> 当我启动服务的时候出现load bus without application context的提示,并且出
>>> 现nullexception 异常代码如下:
>>> 这里有2个问题1、为什么会出现那个提示?
>>> 2、这个异常是怎么出现的?
>>>
>>> 后来我对代码进行了一下修改,增加了loadBusConfig方法,代码如下:
>>> private void loadBusNoConfig(ServletConfig servletConfig)
>>> throws ServletException {
>>>
>>> bus = BusFactory.getDefaultBus();
>>> ResourceManager resourceManager = bus
>>> .getExtension(ResourceManager.class);
>>> resourceManager.addResourceResolver(new
>>> ServletContextResourceResolver(
>>> servletConfig.getServletContext()));
>>>
>>> replaceDestinationFactory();
>>> // Set up the ServletController
>>> controller = createServletController(servletConfig);
>>>
>>> }
>>> 在loadBus方法中 将 super.loadBus(servletConfig)替换成loadBusConfig
>>> (servletConfig);
>>> 并在factory.create()前面加上
>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>> 完整代码如下:
>>> public void loadBus(ServletConfig servletConfig) throws ServletException
>>> {
>>>
>>> loadBusNoConfig(servletConfig);
>>>
>>> // Bus bus = getBus();
>>> // BusFactory.setDefaultBus(bus);
>>> // Endpoint.publish("/HelloWorld", new HelloWorldImpl());
>>>
>>> // You can als use the simple frontend API to do this
>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>
>>> factroy.setBus(bus);
>>> factroy.setServiceClass(HelloWorld.class);
>>> factroy.setAddress("/HelloWorld");
>>> factroy.setServiceBean(helloworldImpl);
>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>>
>>>
>>> factroy.create();
>>>
>>> }
>>> 启动服务 前面的2个问题解决了 但是还是报了异常:
>>> 以上是在openfire的环境下通过插件实现,我开始怀疑是不是环境出了问题 于是
>>> 将相同的一份代码 放到一个WEB工程下通过TOMCAT启动,启动过程中报:
>>> 有人说是版本的问题,我仔细核对了我的版本,我用的是JDK1.5 CXF版本为
>>> 2.1.8,完全符合官网上的标准。
>>> 以上就是我问题的描述,希望你能在百忙之中抽点时间帮助小弟解答一下,小弟将
>>> 不胜感激!
>>>
>>>
>>> 陈世伟
>>>
>>
>
> --
> 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
> 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com
> 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com
> 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
> ----
> Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
>
>
--
View this message in context: http://old.nabble.com/Re%3A-%E6%B1%82%E5%8A%A9-tp26809203p26821979.html
Sent from the cxf-zh mailing list archive at Nabble.com.
�� 2009-12-17 10:07, ����ΰ д��:
> ллWillem
> ���һ��ţ�����openfire�в������Webservice�õ���CXF�ǽ�SPRING����ģ�����Ӧ�ò������spring�汾��ͻ�����⡣���ڳ��ֵ��쳣��
> org.apache.cxf.BusException: No binding factory for namespace
> org.apache.cxf.service.factory.ServiceConstructionException: Could not
> resolve a binding for null:
> ��z�Ļظ���˵��Thread.currentThread().getContextClassLoader()����˵������ϸ����
>
> z����-2 wrote:
>
>> ����
>>
>> org.apache.cxf.service.factory.ServiceConstructionException: Could not
>> resolve a binding for null:
>>
>> �����openfire�Ļ�ṹ��ʵ�ʼ���, ������CXF��������������ܾ���
>> ��Thread.currentThread().getContextClassLoader()
>>
>>
>> �� 2009-12-16 18:39, Willem Jiang �:
>>
>>> CXF ֧��Servlet Transport�� ����openfire�����в����ʱ�������ʲô���⣿
>>> �Dz�����ΪSpring �汾��ͻ���ֵ����⡣
>>>
>>> ��������Stack trace 4��������bus��������г��ֵ����⡣
>>> ����Ժú��о�һ��CXF bus �������ֵĴ��롣
>>>
>>> ������������й�CXF�����⣬�����㷢��cxf...@googlegroups.com, ��������
>>> ��Χ���һЩ��
>>> ���ұ���Ҳ�ܴ���������л��档
>>>
>>> ����
>>>
>>> ����ΰ wrote:
>>>
>>>
>>>> ������
>>>> ���
>>>> �����һ����Ŀ��ʹ��CXF�������кܶ������˼������⣬������Ҳ���˺�
>>>> ������ ʼ��û�н��ϣ������ָ��һ�������ż��¡�
>>>> �ҵ���Ŀ���и���Ʒ��� ����Ҫ��openfire ��webservice�����һ��ͨ��
>>>> �����ӿ� �õ������openfire�������ݡ�Ŀǰ�ҵ�ʵ�ַ�����ͨ��д
>>>> openfire���4ʵ��webservice�Ĺ��ܡ���ʵ�ֵĹ���з������SPRING��CXF ��
>>>> openfire�Դ��JETTY������ ����ֺܶ����⣬���Ǿ��뵽��spring��CXF���롣
>>>> ����һ������extends CXFNonSpringServlet ����ಢ���չٷ�������
>>>> OVERRIDE�� loadBus �������������£�
>>>> public void loadBus(ServletConfig servletConfig) throws ServletException
>>>> {
>>>>
>>>> // You can als use the simple frontend API to do this
>>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>>
>>>> factroy.setBus(bus);
>>>> factroy.setServiceClass(HelloWorld.class);
>>>> factroy.setAddress("/HelloWorld");
>>>> factroy.setServiceBean(helloworldImpl);
>>>> factroy.create();
>>>> }
>>>> ����������ʱ�����load bus without application context����ʾ�����ҳ�
>>>> ��nullexception �쳣�������£�
>>>> ������2������1��Ϊʲô������Ǹ���ʾ��
>>>> 2������쳣����ô���ֵģ�
>>>>
>>>> ��4�ҶԴ��������һ���ģ������loadBusConfig�������������£�
>>>> private void loadBusNoConfig(ServletConfig servletConfig)
>>>> throws ServletException {
>>>>
>>>> bus = BusFactory.getDefaultBus();
>>>> ResourceManager resourceManager = bus
>>>> .getExtension(ResourceManager.class);
>>>> resourceManager.addResourceResolver(new
>>>> ServletContextResourceResolver(
>>>> servletConfig.getServletContext()));
>>>>
>>>> replaceDestinationFactory();
>>>> // Set up the ServletController
>>>> controller = createServletController(servletConfig);
>>>>
>>>> }
>>>> ��loadBus������ �� super.loadBus(servletConfig)�滻��loadBusConfig
>>>> (servletConfig);
>>>> ����factory.create()ǰ�����
>>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>>> ����������£�
>>>> public void loadBus(ServletConfig servletConfig) throws ServletException
>>>> {
>>>>
>>>> loadBusNoConfig(servletConfig);
>>>>
>>>> // Bus bus = getBus();
>>>> // BusFactory.setDefaultBus(bus);
>>>> // Endpoint.publish("/HelloWorld", new HelloWorldImpl());
>>>>
>>>> // You can als use the simple frontend API to do this
>>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>>
>>>> factroy.setBus(bus);
>>>> factroy.setServiceClass(HelloWorld.class);
>>>> factroy.setAddress("/HelloWorld");
>>>> factroy.setServiceBean(helloworldImpl);
>>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>>>
>>>>
>>>> factroy.create();
>>>>
>>>> }
>>>> ����� ǰ���2���������� ���ǻ��DZ����쳣��
>>>> ��������openfire�Ļ�����ͨ����ʵ�֣��ҿ�ʼ�����Dz��ǻ����������� ����
>>>> ����ͬ��һ�ݴ��� �ŵ�һ��WEB������ͨ��TOMCAT��������б���
>>>> ����˵�ǰ汾�����⣬����ϸ�˶����ҵİ汾�����õ���JDK1.5 CXF�汾Ϊ
>>>> 2.1.8����ȫ��Ϲ����ϵı���
>>>> ���Ͼ��������������ϣ�������ڰ�æ֮�г��ʱ�����С�ܽ��һ�£�С�ܽ�
>>>> ��ʤ�м���
>>>>
>>>>
>>>> ����ΰ
>>>>
>>>>
>>>
>>>
>> --
>> ���յ�����Ϣ������������ Google ��̳��cxf-zh����̳��
>> Ҫ�ڴ���̳�����뷢�����ʼ��� cxf...@googlegroups.com
>> Ҫ�˶�����̳���뷢�ʼ��� cxf-zh-un...@googlegroups.com
>> ���ѡ���ͨ�� http://groups.google.com/group/cxf-zh?hl=zh-CN ���ʸ���̳
>> ----
>> Apache CXF ��ҳ http://cwiki.apache.org/confluence/display/CXF/Index
>>
>>
>>
>
梁文龙-2 wrote:
>
> 没记错的话Bus在初始化的时候首先是检查
> Thread.currentThread().getContextClassLoader(), 如果有值就用它来加载cxf-
> x.x.x.jar!/META-INF下的那些配置文件, 而如果在Bus初始化的时候, 当前Thread
> 上的ContextClassLoader被指定为了不同的值, 比如openfire为每个插件使用各自
> 的ClassLoader, 就像OSGI那样, 那这个问题就会出来了.
>
> 于 2009-12-17 10:07, 陈世伟 写道:
>> 谢谢Willem
>> 给我回信,我在openfire中部署这个Webservice用到的CXF是将SPRING分离的,所以应该不会出现spring版本冲突的问题。现在出现的异常是
>> org.apache.cxf.BusException: No binding factory for namespace
>> org.apache.cxf.service.factory.ServiceConstructionException: Could not
>> resolve a binding for null:
>> 在梁的回复中说到Thread.currentThread().getContextClassLoader(),能说的再详细点吗?
>>
>> 梁文龙-2 wrote:
>>
>>> 关于
>>>
>>> org.apache.cxf.service.factory.ServiceConstructionException: Could not
>>> resolve a binding for null:
>>>
>>> 不清楚openfire的基础结构和实际技术, 但是引发CXF的这个错误的最大可能就在
>>> 于Thread.currentThread().getContextClassLoader()
>>>
>>>
>>> 于 2009-12-16 18:39, Willem Jiang 写道:
>>>
>>>> CXF 支持Servlet Transport, 你在openfire容器中部署的时候出现了什么问题?
>>>> 是不是因为Spring 版本冲突出现的问题。
>>>>
>>>> 单从你给的Stack trace 来看可能是bus创建过程中出现的问题。
>>>> 你可以好好研究一下CXF bus 创建部分的代码。
>>>>
>>>> 还有你如果还有有关CXF的问题,建议你发到cxf...@googlegroups.com, 这样讨论
>>>> 范围会大一些,
>>>> 而且别人也能从你的讨论中获益。
>>>>
>>>> 姜宁
>>>>
>>>> 陈世伟 wrote:
>>>>
>>>>
>>>>> 姜宁:
>>>>> 你好
>>>>> 最近在一个项目上使用CXF,发现有很多问题百思不得其解,在网上也查了很
>>>>> 多资料 始终没有解决。希望你能指点一二,打扰见谅。
>>>>> 我的项目里有个设计方案 就是要把openfire 和webservice整合在一起,通过
>>>>> 发布接口 让第三方访问openfire里面的数据。目前我的实现方案是通过写
>>>>> openfire插件来实现webservice的功能。在实现的过程中发现整合SPRING的CXF 在
>>>>> openfire自带的JETTY容器中 会出现很多问题,于是就想到将spring与CXF分离。
>>>>> 起初第一步,我extends CXFNonSpringServlet 这个类并按照官方的例子
>>>>> OVERRIDE了 loadBus 这个方法,代码如下:
>>>>> public void loadBus(ServletConfig servletConfig) throws
>>>>> ServletException
>>>>> {
>>>>>
>>>>> // You can als use the simple frontend API to do this
>>>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>>>
>>>>> factroy.setBus(bus);
>>>>> factroy.setServiceClass(HelloWorld.class);
>>>>> factroy.setAddress("/HelloWorld");
>>>>> factroy.setServiceBean(helloworldImpl);
>>>>> factroy.create();
>>>>> }
>>>>> 当我启动服务的时候出现load bus without application context的提示,并且出
>>>>> 现nullexception 异常代码如下:
>>>>> 这里有2个问题1、为什么会出现那个提示?
>>>>> 2、这个异常是怎么出现的?
>>>>>
>>>>> 后来我对代码进行了一下修改,增加了loadBusConfig方法,代码如下:
>>>>> private void loadBusNoConfig(ServletConfig servletConfig)
>>>>> throws ServletException {
>>>>>
>>>>> bus = BusFactory.getDefaultBus();
>>>>> ResourceManager resourceManager = bus
>>>>> .getExtension(ResourceManager.class);
>>>>> resourceManager.addResourceResolver(new
>>>>> ServletContextResourceResolver(
>>>>> servletConfig.getServletContext()));
>>>>>
>>>>> replaceDestinationFactory();
>>>>> // Set up the ServletController
>>>>> controller = createServletController(servletConfig);
>>>>>
>>>>> }
>>>>> 在loadBus方法中 将 super.loadBus(servletConfig)替换成loadBusConfig
>>>>> (servletConfig);
>>>>> 并在factory.create()前面加上
>>>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>>>> 完整代码如下:
>>>>> public void loadBus(ServletConfig servletConfig) throws
>>>>> ServletException
>>>>> {
>>>>>
>>>>> loadBusNoConfig(servletConfig);
>>>>>
>>>>> // Bus bus = getBus();
>>>>> // BusFactory.setDefaultBus(bus);
>>>>> // Endpoint.publish("/HelloWorld", new HelloWorldImpl());
>>>>>
>>>>> // You can als use the simple frontend API to do this
>>>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>>>
>>>>> factroy.setBus(bus);
>>>>> factroy.setServiceClass(HelloWorld.class);
>>>>> factroy.setAddress("/HelloWorld");
>>>>> factroy.setServiceBean(helloworldImpl);
>>>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>>>>
>>>>>
>>>>> factroy.create();
>>>>>
>>>>> }
>>>>> 启动服务 前面的2个问题解决了 但是还是报了异常:
>>>>> 以上是在openfire的环境下通过插件实现,我开始怀疑是不是环境出了问题 于是
>>>>> 将相同的一份代码 放到一个WEB工程下通过TOMCAT启动,启动过程中报:
>>>>> 有人说是版本的问题,我仔细核对了我的版本,我用的是JDK1.5 CXF版本为
>>>>> 2.1.8,完全符合官网上的标准。
>>>>> 以上就是我问题的描述,希望你能在百忙之中抽点时间帮助小弟解答一下,小弟将
>>>>> 不胜感激!
>>>>>
>>>>>
>>>>> 陈世伟
>>>>>
>>>>>
>>>>
>>>>
>>> --
>>> 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
>>> 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com
>>> 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com
>>> 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
>>> ----
>>> Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
>>>
>>>
>>>
>>
>
> --
> 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
> 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com
> 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com
> 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
> ----
> Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
>
>
--
View this message in context: http://old.nabble.com/Re%3A-%E6%B1%82%E5%8A%A9-tp26809203p26824207.html
�� 2009-12-17 15:24, ����ΰ д��:
> ������˵��openfire�ڼ��ز����ʱ���õ��Լ���URLClassLoader
> ���������Ѿ���CXF-jar�ŵ������Ӧ��·���У������ڳ�ʼ��BUS��ʱ�������URLClassLoaderӦ���ǿ����ҵ���Ӧ����İɣ�
>
> z����-2 wrote:
>
>> û�Ǵ�Ļ�Bus�ڳ�ʼ����ʱ�������Ǽ��
>> Thread.currentThread().getContextClassLoader(), �����ֵ������4����cxf-
>> x.x.x.jar!/META-INF�µ���Щ�����ļ�, �������Bus��ʼ����ʱ��, ��ǰThread
>> �ϵ�ContextClassLoader��ָ��Ϊ�˲�ͬ��ֵ, ����openfireΪÿ����ʹ�ø���
>> ��ClassLoader, ����OSGI����, ���������ͻ��4��.
>>
>> �� 2009-12-17 10:07, ����ΰ д��:
>>
>>> ллWillem
>>> ���һ��ţ�����openfire�в������Webservice�õ���CXF�ǽ�SPRING����ģ�����Ӧ�ò������spring�汾��ͻ�����⡣���ڳ��ֵ��쳣��
>>> org.apache.cxf.BusException: No binding factory for namespace
>>> org.apache.cxf.service.factory.ServiceConstructionException: Could not
>>> resolve a binding for null:
>>> ��z�Ļظ���˵��Thread.currentThread().getContextClassLoader()����˵������ϸ����
>>>
>>> z����-2 wrote:
>>>
>>>
>>>> ����
>>>>
>>>> org.apache.cxf.service.factory.ServiceConstructionException: Could not
>>>> resolve a binding for null:
>>>>
>>>> �����openfire�Ļ�ṹ��ʵ�ʼ���, ������CXF��������������ܾ���
>>>> ��Thread.currentThread().getContextClassLoader()
>>>>
>>>>
>>>> �� 2009-12-16 18:39, Willem Jiang �:
>>>>
>>>>
>>>>> CXF ֧��Servlet Transport�� ����openfire�����в����ʱ�������ʲô���⣿
>>>>> �Dz�����ΪSpring �汾��ͻ���ֵ����⡣
>>>>>
>>>>> ��������Stack trace 4��������bus��������г��ֵ����⡣
>>>>> ����Ժú��о�һ��CXF bus �������ֵĴ��롣
>>>>>
>>>>> ������������й�CXF�����⣬�����㷢��cxf...@googlegroups.com, ��������
>>>>> ��Χ���һЩ��
>>>>> ���ұ���Ҳ�ܴ���������л��档
>>>>>
>>>>> ����
>>>>>
>>>>> ����ΰ wrote:
>>>>>
>>>>>
>>>>>
>>>>>> ������
>>>>>> ���
>>>>>> �����һ����Ŀ��ʹ��CXF�������кܶ������˼������⣬������Ҳ���˺�
>>>>>> ������ ʼ��û�н��ϣ������ָ��һ�������ż��¡�
>>>>>> �ҵ���Ŀ���и���Ʒ��� ����Ҫ��openfire ��webservice�����һ��ͨ��
>>>>>> �����ӿ� �õ������openfire�������ݡ�Ŀǰ�ҵ�ʵ�ַ�����ͨ��д
>>>>>> openfire���4ʵ��webservice�Ĺ��ܡ���ʵ�ֵĹ���з������SPRING��CXF ��
>>>>>> openfire�Դ��JETTY������ ����ֺܶ����⣬���Ǿ��뵽��spring��CXF���롣
>>>>>> ����һ������extends CXFNonSpringServlet ����ಢ���չٷ�������
>>>>>> OVERRIDE�� loadBus �������������£�
>>>>>> public void loadBus(ServletConfig servletConfig) throws
>>>>>> ServletException
>>>>>> {
>>>>>>
>>>>>> // You can als use the simple frontend API to do this
>>>>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>>>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>>>>
>>>>>> factroy.setBus(bus);
>>>>>> factroy.setServiceClass(HelloWorld.class);
>>>>>> factroy.setAddress("/HelloWorld");
>>>>>> factroy.setServiceBean(helloworldImpl);
>>>>>> factroy.create();
>>>>>> }
>>>>>> ����������ʱ�����load bus without application context����ʾ�����ҳ�
>>>>>> ��nullexception �쳣�������£�
>>>>>> ������2������1��Ϊʲô������Ǹ���ʾ��
>>>>>> 2������쳣����ô���ֵģ�
>>>>>>
>>>>>> ��4�ҶԴ��������һ���ģ������loadBusConfig�������������£�
>>>>>> private void loadBusNoConfig(ServletConfig servletConfig)
>>>>>> throws ServletException {
>>>>>>
>>>>>> bus = BusFactory.getDefaultBus();
>>>>>> ResourceManager resourceManager = bus
>>>>>> .getExtension(ResourceManager.class);
>>>>>> resourceManager.addResourceResolver(new
>>>>>> ServletContextResourceResolver(
>>>>>> servletConfig.getServletContext()));
>>>>>>
>>>>>> replaceDestinationFactory();
>>>>>> // Set up the ServletController
>>>>>> controller = createServletController(servletConfig);
>>>>>>
>>>>>> }
>>>>>> ��loadBus������ �� super.loadBus(servletConfig)�滻��loadBusConfig
>>>>>> (servletConfig);
>>>>>> ����factory.create()ǰ�����
>>>>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>>>>> ����������£�
>>>>>> public void loadBus(ServletConfig servletConfig) throws
>>>>>> ServletException
>>>>>> {
>>>>>>
>>>>>> loadBusNoConfig(servletConfig);
>>>>>>
>>>>>> // Bus bus = getBus();
>>>>>> // BusFactory.setDefaultBus(bus);
>>>>>> // Endpoint.publish("/HelloWorld", new HelloWorldImpl());
>>>>>>
>>>>>> // You can als use the simple frontend API to do this
>>>>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>>>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>>>>
>>>>>> factroy.setBus(bus);
>>>>>> factroy.setServiceClass(HelloWorld.class);
>>>>>> factroy.setAddress("/HelloWorld");
>>>>>> factroy.setServiceBean(helloworldImpl);
>>>>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>>>>>
>>>>>>
>>>>>> factroy.create();
>>>>>>
>>>>>> }
>>>>>> ����� ǰ���2���������� ���ǻ��DZ����쳣��
>>>>>> ��������openfire�Ļ�����ͨ����ʵ�֣��ҿ�ʼ�����Dz��ǻ����������� ����
>>>>>> ����ͬ��һ�ݴ��� �ŵ�һ��WEB������ͨ��TOMCAT��������б���
org.apache.cxf.service.factory.ServiceConstructionException: Could not
resolve a binding for http://schemas.xmlsoap.org/wsdl/soap/
依然是这个异常。我将同样的代码放到TOMCAT环境下 可以通过,应该可以证明代码没有问题。
梁文龙-2 wrote:
>
> 唔, 参考一下JEE容器比如tomcat, 它有自己的ClassLoader, 然后再以这个
> ClassLoader为parent为每个web应用再建立各自的ClassLoader, 这样呢, 由
> ClassLoader查找类时的双亲委托机制, parent不能load到child内的class, 而
> child可以load到parent内的class; openfire的插件机制大概也是这样, load一个
> 插件的时候, 将currentThread.contxtClassLoader设为parentClassLoader, 而导
> 致cxf不能load自己的配置文件, 因为parent不能load到child内的资源
>
> 于 2009-12-17 15:24, 陈世伟 写道:
>> 如你所说,openfire在加载插件的时候用到自己的URLClassLoader
>> ,但是我已经将CXF-jar放到了相对应的路径中,我想在初始化BUS的时候用这个URLClassLoader应该是可以找到相应的类的吧?
>>
>> 梁文龙-2 wrote:
>>
>>> 没记错的话Bus在初始化的时候首先是检查
>>> Thread.currentThread().getContextClassLoader(), 如果有值就用它来加载cxf-
>>> x.x.x.jar!/META-INF下的那些配置文件, 而如果在Bus初始化的时候, 当前Thread
>>> 上的ContextClassLoader被指定为了不同的值, 比如openfire为每个插件使用各自
>>> 的ClassLoader, 就像OSGI那样, 那这个问题就会出来了.
>>>
>>> 于 2009-12-17 10:07, 陈世伟 写道:
>>>
>>>> 谢谢Willem
>>>> 给我回信,我在openfire中部署这个Webservice用到的CXF是将SPRING分离的,所以应该不会出现spring版本冲突的问题。现在出现的异常是
>>>> org.apache.cxf.BusException: No binding factory for namespace
>>>> org.apache.cxf.service.factory.ServiceConstructionException: Could not
>>>> resolve a binding for null:
>>>> 在梁的回复中说到Thread.currentThread().getContextClassLoader(),能说的再详细点吗?
>>>>
>>>> 梁文龙-2 wrote:
>>>>
>>>>
>>>>> 关于
>>>>>
>>>>> org.apache.cxf.service.factory.ServiceConstructionException: Could not
>>>>> resolve a binding for null:
>>>>>
>>>>> 不清楚openfire的基础结构和实际技术, 但是引发CXF的这个错误的最大可能就在
>>>>> 于Thread.currentThread().getContextClassLoader()
>>>>>
>>>>>
>>>>> 于 2009-12-16 18:39, Willem Jiang 写道:
>>>>>
>>>>>
>>>>>> CXF 支持Servlet Transport, 你在openfire容器中部署的时候出现了什么问题?
>>>>>> 是不是因为Spring 版本冲突出现的问题。
>>>>>>
>>>>>> 单从你给的Stack trace 来看可能是bus创建过程中出现的问题。
>>>>>> 你可以好好研究一下CXF bus 创建部分的代码。
>>>>>>
>>>>>> 还有你如果还有有关CXF的问题,建议你发到cxf...@googlegroups.com, 这样讨论
>>>>>> 范围会大一些,
>>>>>> 而且别人也能从你的讨论中获益。
>>>>>>
>>>>>> 姜宁
>>>>>>
>>>>>> 陈世伟 wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> 姜宁:
>>>>>>> 你好
>>>>>>> 最近在一个项目上使用CXF,发现有很多问题百思不得其解,在网上也查了很
>>>>>>> 多资料 始终没有解决。希望你能指点一二,打扰见谅。
>>>>>>> 我的项目里有个设计方案 就是要把openfire 和webservice整合在一起,通过
>>>>>>> 发布接口 让第三方访问openfire里面的数据。目前我的实现方案是通过写
>>>>>>> openfire插件来实现webservice的功能。在实现的过程中发现整合SPRING的CXF 在
>>>>>>> openfire自带的JETTY容器中 会出现很多问题,于是就想到将spring与CXF分离。
>>>>>>> 起初第一步,我extends CXFNonSpringServlet 这个类并按照官方的例子
>>>>>>> OVERRIDE了 loadBus 这个方法,代码如下:
>>>>>>> public void loadBus(ServletConfig servletConfig) throws
>>>>>>> ServletException
>>>>>>> {
>>>>>>>
>>>>>>> // You can als use the simple frontend API to do this
>>>>>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>>>>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>>>>>
>>>>>>> factroy.setBus(bus);
>>>>>>> factroy.setServiceClass(HelloWorld.class);
>>>>>>> factroy.setAddress("/HelloWorld");
>>>>>>> factroy.setServiceBean(helloworldImpl);
>>>>>>> factroy.create();
>>>>>>> }
>>>>>>> 当我启动服务的时候出现load bus without application context的提示,并且出
>>>>>>> 现nullexception 异常代码如下:
>>>>>>> 这里有2个问题1、为什么会出现那个提示?
>>>>>>> 2、这个异常是怎么出现的?
>>>>>>>
>>>>>>> 后来我对代码进行了一下修改,增加了loadBusConfig方法,代码如下:
>>>>>>> private void loadBusNoConfig(ServletConfig servletConfig)
>>>>>>> throws ServletException {
>>>>>>>
>>>>>>> bus = BusFactory.getDefaultBus();
>>>>>>> ResourceManager resourceManager = bus
>>>>>>> .getExtension(ResourceManager.class);
>>>>>>> resourceManager.addResourceResolver(new
>>>>>>> ServletContextResourceResolver(
>>>>>>> servletConfig.getServletContext()));
>>>>>>>
>>>>>>> replaceDestinationFactory();
>>>>>>> // Set up the ServletController
>>>>>>> controller = createServletController(servletConfig);
>>>>>>>
>>>>>>> }
>>>>>>> 在loadBus方法中 将 super.loadBus(servletConfig)替换成loadBusConfig
>>>>>>> (servletConfig);
>>>>>>> 并在factory.create()前面加上
>>>>>>> factroy.getServiceFactory().setDataBinding(new AegisDatabinding());
>>>>>>> 完整代码如下:
>>>>>>> public void loadBus(ServletConfig servletConfig) throws
>>>>>>> ServletException
>>>>>>> {
>>>>>>>
>>>>>>> loadBusNoConfig(servletConfig);
>>>>>>>
>>>>>>> // Bus bus = getBus();
>>>>>>> // BusFactory.setDefaultBus(bus);
>>>>>>> // Endpoint.publish("/HelloWorld", new HelloWorldImpl());
>>>>>>>
>>>>>>> // You can als use the simple frontend API to do this
>>>>>>> HelloWorldImpl helloworldImpl = new HelloWorldImpl();
>>>>>>> ServerFactoryBean factroy = new ServerFactoryBean();
>>>>>>>
>>>>>>> factroy.setBus(bus);
>>>>>>> factroy.setServiceClass(HelloWorld.class);
>>>>>>> factroy.setAddress("/HelloWorld");
>>>>>>> factroy.setServiceBean(helloworldImpl);
>>>>>>> factroy.getServiceFactory().setDataBinding(new
>>>>>>> AegisDatabinding());
>>>>>>>
>>>>>>>
>>>>>>> factroy.create();
>>>>>>>
>>>>>>> }
>>>>>>> 启动服务 前面的2个问题解决了 但是还是报了异常:
>>>>>>> 以上是在openfire的环境下通过插件实现,我开始怀疑是不是环境出了问题 于是
>>>>>>> 将相同的一份代码 放到一个WEB工程下通过TOMCAT启动,启动过程中报:
--
View this message in context: http://old.nabble.com/Re%3A-%E6%B1%82%E5%8A%A9-tp26809203p26825771.html