Ant wsimport task failing
ant, java-6, jax-ws, wsimport
Solution
I think that one of the things tedious to use in the approach that you mention (`taskdef` and `wsimport`) is adding environment variables, especially when you want to use SSL and Basic authentication in your web service. I another hand, you can use the `wsimport` tool without define a new task. Something like that:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<project name="generate-client" default="main" basedir=".">
<property name="java.home"
value="X:\Software\jdk1.7.0_11" />
<property name="wsdl.location"
value="http://localhost/wsdl" />
<target name="main">
<exec executable="${java.home}\bin\wsimport.exe">
<arg line="${wsdl.location} -s src -Xdebug -verbose -Xnocompile" />
</exec>
</target>
</project>
Now that you have an idea, you can customize the output directory, add the target version ...
Problem
I have a simple ant script to build my classes from a sdl. Unfortunately wsimport fails immediately. I suspect it has something to do with classpaths. ``` <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport"> <classpath> <pathelement location="${jaxws.lib.dir}/jaxws-tools.jar" /> </classpath> </taskdef> <wsimport wsdl="${project.wsdl.dir}\some.wsdl" destdir="${jaxws.output.dir}" keep="false" extension="true" verbose="true" wsdlLocation="http://localhost/wsdl" target="2.1"> <depends file="${project.wsdl.dir}"/> <produces dir="${jaxws.output.dir}"/> </wsimport> ``` The this is the output it produces: [wsimport] 15 Mar 2013 12:23:25 PM com.sun.xml.bind.v2.util.XmlFactory createDocumentBuilderFactory [wsimport] SEVERE: null [wsimport] java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V [wsimport] at com.sun.xml.bind.v2.util.XmlFactory.createDocumentBuilderFactory(XmlFactory.java:176) [wsimport] at com.sun.tools.xjc.reader.internalizer.DOMForest.(DOMForest.java:162) [wsimport] at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.resetSchema(SchemaCompilerImpl.java:215) [wsimport] at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.(SchemaCompilerImpl.java:114) [wsimport] at com.sun.tools.xjc.api.XJC.createSchemaCompiler(XJC.java:72) [wsimport] at com.sun.tools.ws.wscompile.WsimportOptions.(WsimportOptions.java:152) [wsimport] at com.sun.tools.ws.wscompile.WsimportTool.(WsimportTool.java:89) [wsimport] at com.sun.tools.ws.wscompile.WsimportTool.(WsimportTool.java:92) [wsimport] at com.sun.tools.ws.ant.WsImport2.execute(WsImport2.java:848) [wsimport] at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:103) [wsimport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269) [wsimport] at org.apache.tools.ant.Task.perform(Task.java:364) [wsimport] at org.apache.tools.ant.Target.execute(Target.java:301) [wsimport] at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:135) [wsimport] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.parseBuildFile(InternalAntRunner.java:192) [wsimport] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:401) [wsimport] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138) If I run the commandline create by the verbose logging, on wsimport, from the jax-ws bin directory everything works perfectly ``` [wsimport] command line: wsimport -d C:\Development\Source\ccs\jaxws-output -extension -verbose -target 2.1 C:\Development\Source\ccs\wsdl\some.wsdl -wsdllocation http://localhost/wsdl ``` I tried looking for a solution, but right now I am out of ideas