Running JAXWS 2.1 wsimport on JDK 1.6
In my previous post I wrote about developing a web service endpoint on
JDK 1.6 and at the end of the blog I wrote how to run wsimport command line tool
from the standalone JAXWS 2.1 RI on top of jdk 1.6.
You do not want to put all the jars from @JAXWS_HOME/lib into endorsed
directory. This may work for wsimport command line tool as mentioned in my
previous blog, but will cause error when you try to run Wsimport ant task.
the reason is that Wsimport ant task class will be loaded by the boot
classloader and when it tries to load ant's classes it fails as they are not
loaded by the boot classloader. So in this case it would fail with this error:
taskdef A class needed by class com.sun.tools.ws.ant.WsImport cannot
be found: org/apache/tools/ant/taskdefs/MatchingTask
issue reported for details.
Basically you need to put only two jars in the endorsed directory,
jaxws-api.jar and jaxb-api.jar, see
Directory Mechanism for more details.
You would pretty much do the following to run wsimport, both ant task and
command line tool from JAXWS 2.1 RI on JDK 1.6:
- cp $JAXWS_HOME/lib/jaxws-api.jar c:/jdk6/jre/lib/endorsed
- cp $JAXWS_HOME/lib/jaxb-api.jar c:/jdk6/jre/lib/endorsed
$JAXWS_HOME points to the directory where you installed JAXWS 2.1 RI.