我使用wsimport的jdk 1.7从WSDL创建了WS客户端。 客户端作为独立应用程序运行时,它可以正常工作。
当我在JBoss 7上运行时,我得到了:
[END]
java.lang.UnsupportedClassVersionError: rqbalamWs/com/softwareag/namespace/entirex/xml/mapping/jaxws_asm/package-info : Unsupported major.minor version 0.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at org.apache.cxf.common.util.ASMHelper$TypeHelperClassLoader.defineClass(ASMHelper.java:367)
at org.apache.cxf.common.util.ASMHelper.loadClass(ASMHelper.java:316)
at org.apache.cxf.jaxws.WrapperClassGenerator.generatePackageInfo(WrapperClassGenerator.java:267)
at org.apache.cxf.jaxws.WrapperClassGenerator.createWrapperClass(WrapperClassGenerator.java:169)
at org.apache.cxf.jaxws.WrapperClassGenerator.generate(WrapperClassGenerator.java:122)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.generatedWrapperBeanClass(JaxWsServiceFactoryBean.java:683)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.getExtraClass(JaxWsServiceFactoryBean.java:653)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:440)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:548)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:478)
at org.jboss.wsf.stack.cxf.client.ProviderImpl$JBossWSServiceImpl.createPort(ProviderImpl.java:558)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:345)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:336)
at javax.xml.ws.Service.getPort(Service.java:99)
at rqbalamWs.com.softwareag.namespace.entirex.xml.mapping.RQFXONLN.getDB2RQLIBSOAP11Port(RQFXONLN.java:72)
at rqbalamWs.WsClient.send(WsClient.java:16)
at calypsox.engine.FXBalamEngine.handlePSEventTrade(FXBalamEngine.java:87)
at calypsox.engine.FXBalamEngine.process(FXBalamEngine.java:53)
at com.calypso.engine.Engine$EngineThread.run(Engine.java:1413)
在JBoss上运行时,它是否意味着在类路径中,Apache CXF jar在JDK WS实现之前出现,这会导致错误吗?我应该使用一些Apache CXF向导(eclipse)而不是使用wsimport来创建客户端吗?如果我将从JBoss中删除Apache CXF模块就可以了吗?
wsdl:
<?xml version="1.0" encoding="UTF-8" ?>
- <definitions name="RQFXONLN" targetNamespace="http://namespace.softwareag.com/entirex/xml/mapping" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://namespace.softwareag.com/entirex/xml/mapping" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sn0="urn:com-softwareag-entirex-rpc:DB2RQLIB" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
- <types>
- <xsd:schema targetNamespace="urn:com-softwareag-entirex-rpc:DB2RQLIB">
- <xsd:element name="RQFXONLN">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element name="RQFXONLN_INPUT_DEAL" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="RQFXONLNResponse">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="RQFXONLN_OUTPUT_RC">
- <xsd:simpleType>
- <xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="5" />
<xsd:fractionDigits value="0" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
- <xsd:element name="RQFXONLN_OUTPUT_RC_INFO">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
<xsd:maxLength value="70" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
- <message name="RQFXONLNSoapIn">
<part name="parameters" element="sn0:RQFXONLN" />
</message>
- <message name="RQFXONLNSoapOut">
<part name="parameters" element="sn0:RQFXONLNResponse" />
</message>
- <portType name="DB2RQLIBPort">
- <operation name="RQFXONLN">
<input message="tns:RQFXONLNSoapIn" />
<output message="tns:RQFXONLNSoapOut" />
</operation>
</portType>
- <binding name="DB2RQLIBSOAP11Binding" type="tns:DB2RQLIBPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="RQFXONLN">
<soap:operation soapAction="RQFXONLN" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <binding name="DB2RQLIBSOAP12Binding" type="tns:DB2RQLIBPort">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="RQFXONLN">
<soap12:operation soapAction="RQFXONLN" />
- <input>
<soap12:body use="literal" />
</input>
- <output>
<soap12:body use="literal" />
</output>
</operation>
</binding>
- <service name="RQFXONLN">
- <port name="DB2RQLIBSOAP12Port" binding="tns:DB2RQLIBSOAP12Binding">
<soap12:address location="http://entirextest:9080/wsstack/services/RQFXONLN.DB2RQLIBSOAP12Port/" />
</port>
- <port name="DB2RQLIBSOAP11Port" binding="tns:DB2RQLIBSOAP11Binding">
<soap:address location="http://entirextest:9080/wssta`enter code here`ck/services/RQFXONLN.DB2RQLIBSOAP11Port/" />
</port>
</service>
</definitions>
答案 0 :(得分:1)
我做了一些研究,这个问题似乎与错误的ASM库版本有关。
Apache CXF使用ASM生成类。如果你看一下org.apache.cxf.jaxws.WrapperClassGenerator.generatePackageInfo(String, String, Class<?>)
,你会注意到写入生成类的Java版本是在ASMHelper.Opcodes.V1_5
中定义的。但是,CXF不会在ASMHelper.Opcodes
中定义常量,而是根据ASM库中的Opcodes
类加载它。如果此加载失败(例如因为缺少ASM Opcodes
类),则这些属性保持为0,这会导致您的问题(Unsupported major.minor version 0.0
)。
我能够使用asm:asm:1.5.3
重现问题。
要解决此问题,您必须弄清楚为什么CXF会选择错误的ASM库。请检查您的EAR是否有过时的asm罐子。也许asm是由JBoss加载的,我怀疑。
检查CXF从哪里获取ASM库的最佳方法是将以下代码注入您的应用程序:
Method method = ASMHelper.class.getDeclaredMethod("getASMClass", null);
method.setAccessible(true);
Class asmClass = (Class) method.invoke(new ASMHelper(), null);
System.out.println("ASM location: " + asmClass.getProtectionDomain().getCodeSource().getLocation().getPath());
List<URL> classpaths = Arrays.asList(((URLClassLoader)asmClass.getClassLoader()).getURLs());
System.out.println("Classpath of classloader: " + classpaths);
或使用调试器来调试org.apache.cxf.common.util.ASMHelper.getASMClass()