WebService专栏之xfire集成异常总览
文章目录
- 一、asm.jar包冲突
- 1.1 问题现象
- 1.2 问题定位:
- 1.3 解决方案:
- 二、 Old 1.x 'singleton' attribute in use
- 2.1 问题现象
- 2.2 问题定位
- 2.3 解决方案:
- 三、Unrecognized xbean element mapping
- 3.1 问题定位
- 3.2 解决方案:
- 四、services.xml it does not exist
- 4.1 问题现象
- 4.2 解决方案:
- 五、指定class默认缺省
- 5.1 问题现象:
- 5.2 问题定位
- 5.3 解决方案:
- 六 、解析依赖缺少
- 6.1 问题现象
- 6.2 问题定位:
- 6.3 解决方案:
- 七、发布服务失败
- 7.1 问题现象
- 7.2 解决方案:
一、asm.jar包冲突
1.1 问题现象
nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
1.2 问题定位:
org.springframework.asm-3.0.6.RELEASE.jar 这个jar已在spring中包含,而且这个版本也不一致
1.3 解决方案:
把org.springframework.asm-3.0.6.RELEASE.jar 在项目中删除
二、 Old 1.x ‘singleton’ attribute in use
2.1 问题现象
Configuration problem: Old 1.x ‘singleton’ attribute in use - upgrade to ‘scope’ declaration
注:可以去下载xfire-spring-1.2.6的源码或者反编译,问题主要是修改xml配置文档,无需重新编译的。
2.2 问题定位
原因:spring-4.*不支持singleton=false或者singleton=true写法了。
2.3 解决方案:
- 1.找到xfire-all-1.2.6.jar这个jar包
- 2.用压缩工具打开,找到org/codehaus/xfire/spring/xfire.xml文件
- 3.编辑xfire.xml文件,将singleton=“true” 修改为 scope=“singleton”
- 4.把修改后的xfire-all-1.2.6.jar这个jar包放到lib文件夹中
- 5.重启项目
注:编辑xfire-all-1.2.6.jar,要先复制到桌面上,在用压缩工具打开,进行编辑,在项目中无法编辑的
三、Unrecognized xbean element mapping
问题3:
org.springframework.beans.factory.BeanDefinitionStoreException: Unrecognized xbean element mapping: beans in namespace http://xfire.codehaus.org/config/1.0
3.1 问题定位
Unrecognized xbean element mapping: beans in namespace http://xfire.codehaus.org/config/1.0<
3.2 解决方案:
修改services.xml文件.
原文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0"><!-- 1. 暴露的服务名 2. 自定义命名空间 3. 接口路径 4. 接口实现类路径 --><name>HelloService</name><namespace>CustomNamespaces</namespace><serviceClass>com.gblfy.xfire.service.IHelloService</serviceClass><implementationClass>com.gblfy.xfire.service.impl.HelloServiceImpl</implementationClass></service></beans>
修改后文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans><service xmlns="http://xfire.codehaus.org/config/1.0"><!-- 1. 暴露的服务名 2. 自定义命名空间 3. 接口路径 4. 接口实现类路径 --><name>HelloService</name><namespace>CustomNamespaces</namespace><serviceClass>com.gblfy.xfire.service.IHelloService</serviceClass><implementationClass>com.gblfy.xfire.service.impl.HelloServiceImpl</implementationClass></service>
</beans>
四、services.xml it does not exist
4.1 问题现象
java.io.FileNotFoundException: class path resource [META-INF/xfire/services.xml] cannot be opened because it does not exist
4.2 解决方案:
- 1.META-INF目录下面新建一个xfire文件夹
- 2.把services.xml文件放到这个文件夹里
- 3.再将整个META-INF拷贝到WEB-INF中
- 4.clean一下工程
- 5.重新加载后启动服务就可以了
五、指定class默认缺省
5.1 问题现象:
cannot convert value of type ‘org.codehaus.xfire.spring.editors.ServiceFactoryEditor’ to …
5.2 问题定位
spring-4.*的customEditors获取类型直接指定为Class,而配置默认还是缺省的
5.3 解决方案:
- 1.找到xfire-all-1.2.6.jar这个jar包
- 2.用压缩工具打开,找到org/codehaus/xfire/spring/customEditors.xml 文件
- 3.编辑customEditors.xml文件
- 4.把修改后的xfire-all-1.2.6.jar这个jar包放到lib文件夹中
- 5.重启项目
详细编辑customEditors.xml文件:
把map中间的部分替换为下面即可。
<entry key="org.codehaus.xfire.service.ServiceFactory" value="org.codehaus.xfire.spring.editors.ServiceFactoryEditor"></entry>
源文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans><bean id="xfire.customEditorConfigurer"class="org.springframework.beans.factory.config.CustomEditorConfigurer"><property name="customEditors"><map><entry key="org.codehaus.xfire.service.ServiceFactory"><bean class="org.codehaus.xfire.spring.editors.ServiceFactoryEditor"><property name="transportManager" ref="xfire.transportManager" /></bean></entry></map></property></bean></beans>
修改后:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans><bean id="xfire.customEditorConfigurer"class="org.springframework.beans.factory.config.CustomEditorConfigurer"><property name="customEditors"><map><entry key="org.codehaus.xfire.service.ServiceFactory" value="org.codehaus.xfire.spring.editors.ServiceFactoryEditor"></entry></map></property></bean></beans>
注:编辑xfire-all-1.2.6.jar,要先复制到桌面上,在用压缩工具打开,进行编辑,在项目中无法编辑的
六 、解析依赖缺少
6.1 问题现象
nested exception is java.lang.NoClassDefFoundError: org/jdom/Content
6.2 问题定位:
缺少jdom的jar包
6.3 解决方案:
- 1.下载jdom-1.0.jar
- 2.复制到项目中的lib包下面
- 3.重启项目
jdom-1.0.jar下载链接:
链接 | https://pan.baidu.com/s/1dpuCtD_Kng1rTaiF3dlM6g |
---|---|
提取码 | bqfz |
七、发布服务失败
7.1 问题现象
输入网址:http://localhost:8081/XFireTest/services/HelloService?wsdl
浏览器会显示你所绑定的类或接口名称,如:
Available Services:
MathService [wsdl]
DelService [wsdl]
Generated by XFire ( http://xfire.codehaus.org )
7.2 解决方案:
- 1.重启服务
- 2.换个浏览器试试