异常信息:Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at $Proxy25.required(Unknown Source)
at com.sun.tools.xjc.generator.bean.field.AbstractField.annotateReferenc
e(AbstractField.java:192)
at com.sun.tools.xjc.generator.bean.field.AbstractField.annotate(Abstrac
tField.java:161)
at com.sun.tools.xjc.generator.bean.field.AbstractFieldWithVar.createFie
ld(AbstractFieldWithVar.java:80)
at com.sun.tools.xjc.generator.bean.field.SingleField.<init>(SingleField
.java:94)
at com.sun.tools.xjc.generator.bean.field.SingleField.<init>(SingleField
.java:81)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.tools.xjc.generator.bean.field.GenericFieldRenderer.generate(
GenericFieldRenderer.java:69)
at com.sun.tools.xjc.generator.bean.field.DefaultFieldRenderer.generate(
DefaultFieldRenderer.java:82)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generateFieldDecl(Bean
Generator.java:774)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassBody(Bean
Generator.java:555)
at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.j
ava:258)
at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator
.java:166)
at com.sun.tools.xjc.model.Model.generateCode(Model.java:290)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompiler
Impl.java:284)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompiler
Impl.java:95)
at com.sun.tools.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBMod
elBuilder.java:142)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WS
DLModeler.java:2244)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildMode
l(WSDLModeler.java:191)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLMo
deler.java:137)
at com.sun.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.j
ava:391)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:204)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.tools.ws.Invoker.invoke(Invoker.java:135)
at com.sun.tools.ws.WsImport.main(WsImport.java:57)
Caused by: java.lang.NoSuchMethodException: javax.xml.bind.annotation.XmlElement
Ref.required()
at java.lang.Class.getDeclaredMethod(Class.java:1937)
at com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.
java:112)
... 32 more
异常产生场景: 用jax-ws编写服务器端代码,当使用byte[]参数时,wsgen可以产生配置文件,但是用wsimport导出客户端代码时,报以上异常。
异常原因: 可能是jdk1.6 和 JAXWS2.2.7 版本之间的冲突。
用jdk_home下的wsimport命令使用成功,用JAXWS2.2.7/bin中的wsimport命令出错。
解决方法:
<target name="generate-client-2" depends="wsgen">
<exec executable="${env.JAVA_HOME}/bin/wsimport">
<arg line="-d D:\workspace_PMS\JaxWSProject\build2 -g -keep -s D:\workspace_PMS\JaxWSProject\build2 -verbose http://localhost:8089/JaxWSProject/HelloService?wsdl -p com.ws"/>
</exec>
</target>