Java Reference
In-Depth Information
Dealing with Version Errors in wsgen and wsimport
Problem
There are two different versions of the main web services tools ( wsimport and wsgen ). One
version is included in Java SE 6, and the other is included with Glassfish/Metro. You want to
use the newer libraries, but Java SE includes the older one. In other words, you're getting this
error:
You are running on JDK6 which comes with JAX-WS 2.0 API, but this tool
requires JAX-WS 2.1 API. Use the endorsed standards override mechanism
(http://java.sun.com/javase/6/docs/technotes/guides/standards/),
or use -Xendorsed option.
Solution
Get Java SE 1.6.0_4 or higher, as it ships with JAX-WS 2.1. Or override the older version
using the endorsed directory mechanism.
Discussion
If you're using Java 5, you must include the jaxws-api.jarand jaxb-api.jaron your classpath,
as there is no native support for JAX-WS before Java SE 6, which includes JAX-WS 2.0.
Java SE 6 update 4 is the first release to include JAX-WS 2.1 API within the rt.jar. The easiest
way to deal with this problem is to install that version or newer of Java. If you can't do that
for some reason, then you'll need to pull the proverbial wool over your classloader's eyes.
Let's unpack this a bit. If you open a command prompt and issue the command wsimport
-version , you should see something like the following output, assuming that your Java SE
1.6.0_04+ bin directory is on the path:
JAX-WS RI 2.1.1 in JDK 6
If you're using an older version, it will print JAX-WS 2.0 in JDK 6. So you can upgrade to a
newer version of the JDK that ships with JAX-WS 2.1.
If you have Glassfish/Metro, you can navigate to the bindirectory under your Glassfish in-
stallation and run the same command, wsimport -version . Doing that from within the
Glassfish bindirectory gives me the following output:
JAX-WS RI 2.1.3-hudson-390-
Search WWH ::




Custom Search