wed service客户端在JDK1.7以上无法生成
来源:互联网 发布:旅游网络市场调查 编辑:程序博客网 时间:2024/06/07 01:32
WebService Client Generation Error with JDK8
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; lineNumber: 52; columnNumber: 88; schema_reference: Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by theaccessExternalSchema property.
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 myjava -version
output:
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)
For now, I'm keeping JDK7 as my default Java platform. If there is a way to make JDK8 work please share. Thanks in advance.
11 Answers
Well, I found the solution. (based on http://docs.oracle.com/javase/7/docs/api/javax/xml/XMLConstants.html#ACCESS_EXTERNAL_SCHEMA)
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
That's all. Enjoy JDK 8.
Not an actual answer but more as a reference.
If you are using the jaxws Maven plugin and you get the same error message, add the mentioned property to the plugin configuration:
...<plugin> <groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.3</version> <configuration> <!-- Needed with JAXP 1.5 --> <vmArgs> <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> </vmArgs> </configuration></plugin>
accessExternalSchema=all
value is set by default if you use later versions (like 0.12.3) of theorg.jvnet.jaxb2.maven2:maven-jaxb2-plugin
plugin. – Jon Onstott May 27 at 17:16I was also getting similar type of error in Eclipse during testing a webservice program on glassfish 4.0 web server:java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: bundle://158.0:1/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: Failed to read schema document 'xjc.xsd', because 'bundle' access is not allowed due to restriction set by the accessExternalSchema property.
I have added javax.xml.accessExternalSchema = All
in jaxp.properties
, but doesnot work for me.
However I found a solution here below which work for me:For GlassFish Server, I need to modify thedomain.xml
of the GlassFish, path :<path>/glassfish/domains/domain1
ordomain2/config/domain.xml
) and add, <jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options>
under the<java-config>
tag
....
<java-config>... <jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options></java-config>
...and then restart the GlassFish server
I run ant builds within Eclipse IDE (4.4, Luna, on Windows 7 x64). Rather than modifying the installed JRE lib or any ant scripts (I have multiple projects that include XJC in their builds), I prefer to change Eclipse Settings "External Tools Configurations" and add the following to the VM arguments for the Ant build configuration:
-Djavax.xml.accessExternalSchema=all
If you are using ant you can add a jvmarg to your java calls:
<jvmarg value="-Djavax.xml.accessExternalSchema=all" />
Another solution to address: wiki.netbeans.org
The Web Service Client wizard in the IDE parses the WSDL file when generating a web service client from a web service or WSDL file. You need to modify the IDE configuration file (netbeans.conf) to add the following switch to the netbeans_default_options. You will need to restart the IDE for the change to take effect.
-J-Djavax.xml.accessExternalSchema=all
When deploying to GlassFish you need to enable access to external schema to generate a test client for a web service. To enable access you need to modify the configuration file of the GlassFish Server (GLASSFISH_INSTALL/glassfish/domains/domain1/config/domain.xml) and add the following JVM option element. You will need to restart the server for the change to take effect.
</java-config> ... <jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options></java-config>
Another alternative is to update wsimport.sh shell script by adding the following:
The wsimport.sh is located in this directory:
jaxws-ri.2.2.28/bin
exec "$JAVA" $WSIMPORT_OPTS -Djavax.xml.accessExternalSchema=all -jar "$JAXWS_HOME/lib/jaxws-tools.jar" "$@"
Another reference:If you are using the maven-jaxb2-plugin
, prior to version 0.9.0, you can use the workaround describedon this issue, in which this behaviour affected the plugin.
NetBeans update their tutorial for JDK8 and this Issue:
Getting Started with JAX-WS Web Services -> Enabling Access to External Schema
I used it with a regular maven project, and got it solved with this plugin dependency configuration for running thexjc plugin
:
<plugin> <!-- Needed to run the plugin xjc en Java 8 or superior --> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-2</version> <executions> <execution> <id>set-additional-system-properties</id> <goals> <goal>set-system-properties</goal> </goals> </execution> </executions> <configuration> <properties> <property> <name>javax.xml.accessExternalSchema</name> <value>all</value> </property> <property> <name>javax.xml.accessExternalDTD</name> <value>all</value> </property> </properties> </configuration> </plugin>
thank-you EliuX, it s word I used it with a regular maven project, and got it solved with this plugin dependency configuration for running the xjc plugin:
<plugin> <!-- Needed to run the plugin xjc en Java 8 or superior --> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-2</version> <executions> <execution> <id>set-additional-system-properties</id> <goals> <goal>set-system-properties</goal> </goals> </execution> </executions> <configuration> <properties> <property> <name>javax.xml.accessExternalSchema</name> <value>all</value> </property> <property> <name>javax.xml.accessExternalDTD</name> <value>all</value> </property> </properties> </configuration> </plugin>
Not the answer you're looking for? Browse other questions taggedwebservice-client java-8 netbeans-8 or ask your own question.
- wed service客户端在JDK1.7以上无法生成
- ActiveMQ5.11.1必须在JDK1.7以上版本才能使用。
- java实现ftp上传下载(jdk1.7以上)
- JDK1.7以上javaFTP上传删除文件
- 详细分析intern(),jdk1.7以上版本
- 解决jdk1.4生成二维码问题,因为现下生成二维码的jar包,版本最低支持jdk1.5以上的版本,老的项目中想使用二维码,直接使用jar包无法使用
- 在Eclipse中使用Axis2插件生成Web Service服务端/客户端
- 在Eclipse中使用Axis2插件生成Web Service服务端/客户端
- 在Eclipse中使用Axis2插件生成Web Service服务端/客户端
- 实战Eclipse生成Web Service客户端
- 生成 android web service 客户端代码
- WSDL自动生成Web Service java 客户端
- 利用 Myeclipse 生成 Web Service 客户端代码
- 可靠的web service客户端代码生成
- 小颖反编译工具无法反编译jdk1.5以上的class的解决办法
- 解决ubuntu上eclipse无法打开,提示jvm版本太旧,至少要jdk1.8以上
- switch中能用哪些类型jdk1.7及以上
- spring2.5使用jdk1.7及以上解决办法
- js添加键盘是快捷键总结
- Makefile.am 文件介绍
- hdoj 3622 Bomb Game 【2-sat + 二分搜索】
- 单链表的基本操作
- 编译升级内核时需要安装的六个包
- wed service客户端在JDK1.7以上无法生成
- pySphere 管理 VCenter
- android : 使用注解初始化控件
- 动画
- PHP 实现多网站共享用户SESSION 数据解决方案
- windows服务
- POJ 3126:Prime Path
- 随笔-property follows cocoa naming convention for returning 'owned' objects
- Django Models的数据类型 汇总