Apache CXF 在 WebLogic 9.2 上的问题定位分析及权宜之计
同样的程序在 Tomcat 5.5.16/25 以及 Jetty 5.1.12 上都能够成功部署及运行,但是部署到 WebLogic 9.2 上时出错
org.springframework.web.context.ContextLoader initWebApplicationContext
FATAL: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxWebService': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: portName
Caused by: java.lang.NoSuchMethodError: portName
at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.getEndpointName(JaxWsImplementorInfo.java:154)
at org.apache.cxf.jaxws.support.JaxWsServiceConfiguration.getEndpointName(JaxWsServiceConfiguration.java:89)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.getEndpointName(ReflectionServiceFactoryBean.java:983)
at org.apache.cxf.frontend.AbstractEndpointFactory.createEndpoint(AbstractEndpointFactory.java:91)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:107)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:147)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1179)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1145)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:279)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:360)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:241)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
从 Stack Trace 来分析,Spring 在 ContextLoaderListener 进行加载配置文件时出错了。
通过查看 JaxWsImplementorInfo.java:154 的源程序
portName = wsAnnotations.get(x).portName();
private List<WebService> wsAnnotations = new ArrayList<WebService>(2);
package javax.jws;import java.lang.annotation.Annotation;public interface WebService extends Annotation{ public abstract String name(); public abstract String targetNamespace(); public abstract String serviceName(); public abstract String wsdlLocation(); public abstract String endpointInterface();}
package javax.jws;import java.lang.annotation.Annotation;public interface WebService extends Annotation{ public abstract String name(); public abstract String targetNamespace(); public abstract String serviceName(); public abstract String wsdlLocation(); public abstract String endpointInterface(); public abstract String portName();}
<?xml version="1.0" encoding="UTF-8"?><weblogic-web-app><container-descriptor><prefer-web-inf-classes>true</prefer-web-inf-classes></container-descriptor></weblogic-web-app>
FATAL: Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxWebService': Invocation of init method failed; nested exception is java.lang.LinkageError: Class javax/xml/namespace/QName violates loader constraintsCaused by: java.lang.LinkageError: Class javax/xml/namespace/QName violates loader constraints at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:186) at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:25) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:84) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:41) at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:104) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:49) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:372) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:236) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55) at jrockit.reflect.InitialMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210) at javax.xml.bind.ContextFinder.find(ContextFinder.java:366) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574) at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContext(JAXBDataBinding.java:377) at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:182) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:244) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:272) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:146) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:89) at org.apache.cxf.frontend.AbstractEndpointFactory.createEndpoint(AbstractEndpointFactory.java:83) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:107) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:147)
set CLASSPATH_CXF=X:/xyz/geronimo-ws-metadata_2.0_spec-1.1.1.jarset CLASSPATH=%CLASSPATH_CXF%;%CLASSPATH%;%MEDREC_WEBLOGIC_CLASSPATH%