idea 创建Web Service Client 报错 java.lang.AssertionError: org.xml.sax.SAXParseException; systemId:

创建webservice的客户端报如下错误:

[WARNING] schema_reference: ���� accessExternalSchema �������õ����ƶ������� 'http' ����, ����޷���ȡ�����ĵ� 'HelloWorld?xsd=1'��
  http://localhost:9000/HelloWorld?wsdl#types?schema1�ĵ� 4 ��

Exception in thread "main" java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: jar:file:/D:/developmentCode/IdeaCode/serviceServer/lib/jaxb-xjc.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: ���� accessExternalSchema �������õ����ƶ������� 'file' ����, ����޷���ȡ�����ĵ� 'xjc.xsd'��
	at com.sun.tools.xjc.SchemaCache.newValidator(SchemaCache.java:80)
	at com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet.apply(SCDBasedBindingSet.java:237)
	at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:541)
	at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:269)
	at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:95)
	at com.sun.tools.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:142)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2244)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:191)
	at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:137)
	at com.sun.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java: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:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.tools.ws.Invoker.invoke(Invoker.java:135)
	at com.sun.tools.ws.WsImport.main(WsImport.java:57)
Caused by: org.xml.sax.SAXParseException; systemId: jar:file:/D:/developmentCode/IdeaCode/serviceServer/lib/jaxb-xjc.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: ���� accessExternalSchema �������õ����ƶ������� 'file' ����, ����޷���ȡ�����ĵ� 'xjc.xsd'��
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4154)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaFatalError(XSDHandler.java:4133)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2174)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:2084)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:1014)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:625)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:610)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:569)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:535)
	at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:254)
	at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:638)
	at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:670)
	at com.sun.tools.xjc.SchemaCache.newValidator(SchemaCache.java:77)
	... 17 more
Done

原因:

因为我的jre和jdk都用的是jdk8
而刚好jaxb-xjc-2.2.7对jdk8有这个bug,bug详情如下:
https://bugs.openjdk.java.net/browse/JDK-8020999?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

解决方案:

Create a file named jaxp.properties (if it doesn’t exist) under /path/to/jdk1.8.0/jre/lib and then write this line in it:

1.在jre的lib目录下创建jaxp.properties文件
2.文件中添加如下内容
javax.xml.accessExternalSchema = all

你可能感兴趣的:(webservice)