本地tomcat部署webserivce项目正常,但是放到weblogic下却又异常:
<User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authWebService': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: portName.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authWebService': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: portName
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
...
java.lang.NoSuchMethodError: portName
at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.initialize(JaxWsImplementorInfo.java:307)
at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.<init>(JaxWsImplementorInfo.java:60)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:385)
....
经查,原因为weblogic自带的weblogic.jar与CXF框架的geronimo-ws-metadata_2.0_spec-1.1.3.jar冲突所致,weblogic启动时默认优先加载了weblogic.jar,因而无法加载geronimo-ws-metadata_2.0_spec-1.1.3.jar中的方法
解决办法:把geronimo-ws-metadata_2.0_spec-1.1.3.jar复制到%WL_HOME%serverlib目录下(%WL_HOME%一般为:wls9eaweblogic92),然后修改startWebLogic.cmd文件(windows系统修改startWebLogic.cmd文件,linux系统则要修改startWebLogic.sh文件),将set SAVE_CLASSPATH=%CLASSPATH%行内容修改为:
set SAVE_CLASSPATH=%WL_HOME%serverlibgeronimo-ws-metadata_2.0_spec-1.1.3.jar%CLASSPATH%,
即使geronimo-ws-metadata_2.0_spec-1.1.3.jar优先加载即解决了冲突所致报错的问题。