用CXF中的wsdl2java工具时抛出SAXParseException,提示accessExternalSchema属性设置的限制而不允许file访问 G:\myeclipseworkspace\WS-client\src>wsdl2java http://192.168.1.4/server?wsdl Exception in thread "main" java.lang.AssertionError: org.xml.sax.SAXParseExcepti on; systemId: jar:file:/F:/apache-cxf-3.0.0/lib/jaxb-xjc-2.2.7.jar!/com/sun/tool s/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; s chema_reference: 由于 accessExternalSchema 属性设置的限制而不允许 ""file"" 访问, 因此无法读取方案文档 ""xjc.xsd""。 at com.sun.tools.xjc.SchemaCache.newValidator(SchemaCache.java:80) at com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet.apply(SCDBas edBindingSet.java:237) at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:541) at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompiler Impl.java:269) at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompiler Impl.java:95) at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initiali ze(JAXBDataBinding.java:460) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJ avaContainer.java:714) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJav aContainer.java:270) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaCon tainer.java:164) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaCon tainer.java:412) at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.ja va:103) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86) at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184) Caused by: org.xml.sax.SAXParseException; systemId: jar:file:/F:/apache-cxf-3.0. 0/lib/jaxb-xjc-2.2.7.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xs d; lineNumber: 52; columnNumber: 88; schema_reference: 由于 accessExternalSchema 属性设置的限制而不允许 ""file"" 访问, 因此无法读取方案文档 ""xjc.xsd""。 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAX ParseException(ErrorHandlerWrapper.java:203) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalErro r(ErrorHandlerWrapper.java:177) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError( XMLErrorReporter.java:441) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.repo rtSchemaErr(XSDHandler.java:4162) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.repo rtSchemaFatalError(XSDHandler.java:4141) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getS chemaDocument(XSDHandler.java:2168) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reso lveSchema(XSDHandler.java:2078) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.cons tructTrees(XSDHandler.java:1008) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.pars eSchema(XSDHandler.java:620) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema (XMLSchemaLoader.java:616) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGramma r(XMLSchemaLoader.java:574) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGramma r(XMLSchemaLoader.java:540) at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.n ewSchema(XMLSchemaFactory.java:255) 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) ... 13 more |
|
已经找到原因了, 因为我的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 |
|
50分 |
刚好也遇到这个问题,看到这个才知道原因
|