JDK8 的 WebService 客户端生成错误 [英] WebService Client Generation Error with JDK8

查看:34
本文介绍了JDK8 的 WebService 客户端生成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的项目中使用 Web 服务.我使用 NetBeans,所以我右键单击我的项目并尝试添加一个新的Web 服务客户端".我上次检查时,这是创建 Web 服务客户端的方法.但它导致了一个 AssertionError,说:

I need to consume a web service in my project. I use NetBeans so I right-clicked on my project and tried to add a new "Web Service Client". Last time I checked, this was the way to create a web service client. But it resulted in an AssertionError, saying:

java.lang.AssertionError: org.xml.sax.SAXParseException;systemId: jar:file:/path/to/glassfish/modules/jaxb-osgi.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd;行号:52;列数:88;schema_reference:无法读取架构文档xjc.xsd",因为 accessExternalSchema 属性设置的限制不允许文件"访问.

java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: jar:file:/path/to/glassfish/modules/jaxb-osgi.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.

NetBeans 的默认 Java 平台是 JDK8(Oracle 的官方版本),所以当我更改我的 netbeans.conf 文件并将 JDK7(也来自 Oracle)设为我的默认版本时,一切正常.所以我认为问题出在JDK8上.这是我的 java -version 输出:

The default Java platform for NetBeans was JDK8 (Oracle's official version), so when I changed my netbeans.conf file and made JDK7 (from Oracle, as well) as my default, everything worked fine. So I think the problem is with JDK8. Here is my java -version output:

java 版本1.8.0"
Java(TM) SE 运行时环境(构建 1.8.0-b132)
Java HotSpot(TM) 64 位服务器 VM(构建 25.0-b70,混合模式)

java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

目前,我将 JDK7 作为我的默认 Java 平台.如果有什么方法可以让 JDK8 正常工作,请分享.

For now, I'm keeping JDK7 as my default Java platform. If there is a way to make JDK8 work please share.

推荐答案

好吧,我找到了解决方案.(基于 http://docs.oracle.com/javase/7/docs/api/javax/xml/XMLConstants.html#ACCESS_EXTERNAL_SCHEMA)

Well, I found the solution. (based on http://docs.oracle.com/javase/7/docs/api/javax/xml/XMLConstants.html#ACCESS_EXTERNAL_SCHEMA)

/path/to/jdk1.8.0/jre/lib下创建一个名为jaxp.properties的文件(如果不存在的话),然后写这一行其中:

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:

javax.xml.accessExternalSchema = all

仅此而已.享受 JDK 8.

That's all. Enjoy JDK 8.

这篇关于JDK8 的 WebService 客户端生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆