当使用CXF2.0.3的Web系统从Windows移植到AI­X时发生的奇怪错误

FredWorks 2008-06-02 03:54:57
在Windows XP + Tomcat6 + JDK6 下系统工作得很好,但是当移植到AIX的时候,发现无法启动。原因是读取配置文件的时候,
报错。从错误消息看,似乎是当解析<property name="wrapped" value="true" /> 的时
候,PropertiesDescripter没有返回正确的writeMethod(似乎返回的是null,但是我无法在AIX环境下单步调试,这是
我结合报错的消息看了源代码以后的猜测)。但是在Window的环境下工作得很好,单步调试的时候,可以看到正确执行了相关代码的。

想问一下,这是spring对CXF的支持的代码有问题还是CXF本身的代码有问题,还是我配置不对?


这是出错的配置:

<jaxws:endpoint
id="serviceForNetGeo"
implementor="#serviceForNetGeoWS"


implementorClass="cn.com.gxlu.fiberscheduler.webservice.implementation.Serv­iceForNetGeoImpl"
address="${FiberScheduler.address}/ServiceForNetGeo">
<jaxws:serviceFactory>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="true" />
<property name="dataBinding" ref="serverAegisBean" />
</bean>
</jaxws:serviceFactory>
</jaxws:endpoint>



这是错误log:

Jun 2, 2008 3:19:02 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
Throwable occurred: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean' defined in ServletContext resource [/WEB-INF/config/applicationContext-webservice.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [boolean] for property 'wrapped'; nested exception is java.lang.IllegalArgumentException: Method must not be null
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [boolean] for property 'wrapped'; nested exception is java.lang.IllegalArgumentException: Method must not be null
Caused by: java.lang.IllegalArgumentException: Method must not be null
at java.lang.Throwable.<init>(Throwable.java:67)
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.core.MethodParameter.<init>(MethodParameter.java:78)
at org.springframework.core.MethodParameter.<init>(MethodParameter.java:64)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380)



...全文
138 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
FredWorks 2008-06-05
  • 打赏
  • 举报
回复
抱歉一句,;不是ClassInfo对象,是BeanInfo对象。这些类都在java.beans包底下可以找到
FredWorks 2008-06-05
  • 打赏
  • 举报
回复
CXF2.0.3到2.0.5都试过了,是一样的问题。spring是2.0.8。
后来我作了在AIX平台下的JDK5和JDK6的测试,根据测试结果和看Spring,CXF的源代码得出一个结论,那时似乎这个bug来自AIX平台下的jdk6版本,和Spring和CXF都没有关系。

结论是这样的:

当Spring解析了xml配置文件以后,会把bean配置用一个ClassInfo对象的实例来描述,把bean的属性用PropertyDescriptor来描述。在初始化bean的时候,会根据这些ClassInfo和PropertyDescriptor的实例来组装bean。其中,PropertyDescriptor保存了bean的属性的名字,值,setter方法和getter方法,在初始化的时候,会调用setter方法来为bean的属性赋值。问题就出在这里。PropertyDescriptor中保存的其他三个信息都是正确的,偏偏setter方法是null。所以当spring尝试通过反射调用setter方法的时候,就出错了。

那么就要问了,Spring如何得到ClassInfo和PropertyDescriptor对象的实例的呢?它是通过JDK提供的Introspector.getBeanInfo(beanClass)来得到ClassInfo,而通过this.beanInfo.getPropertyDescriptors()来得到PropertyDescriptor的。而Introspector,ClassInfo和PropertyDescriptor都是JDK提供的类。

而我的代码在Windows平台下的JDK5和JDK6中运行都没有问题,在AIX平台下的JDK5 32位和JDK5 64位中运行也没有问题,只在AIX平台下的JDK6 32位和JDK6 64位中运行都有问题。换句话说,就是这应该是AIX平台下的JDK6自己的bug。

对此不知各位有和看法?
YuLimin 2008-06-05
  • 打赏
  • 举报
回复
升级CXF。

Spring的版本是多少?
FredWorks 2008-06-03
  • 打赏
  • 举报
回复
解释一下,“Failed to convert property value of type [java.lang.String] to required type [boolean] for property 'wrapped'”这个错误信息并不完全准确。因为xml文件是成功解析了的。
我看了spring的源代码,在这个部分,解析xml是成功的。解析完了以后,会生成一个PropertyDescriptor的实例,这个实例里面保存了属性的名称,值,setter方法和getter方法。错误出在其他信息都是正确的,偏偏setter方法这个信息没能得到,PropertyDescriptor里面存储的setter方法是null,所以spring尝试用反射去给bean设值的时候,发现无法调用用setter方法。
这个PropertyDescriptor对象是jdk定义的,不是spring定义的。

现在的问题是一模一样的发布版本,在windows下工作的很好,在AIX下出问题。jdk的版本号都是一样的,不知道是不是AIX下的jdk和Windows下的jdk实现不一样。感觉应该不会才对。

到目前未知还没有找到原因。
jdlsfl 2008-06-03
  • 打赏
  • 举报
回复
Failed to convert property value of type [java.lang.String] to required type [boolean] for property 'wrapped'

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧