O'Reilly logo

Java SOA Cookbook by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.jar and jaxb-api.jar on 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required