0

try to generate jax-ws wsdl file from a java application service through wsgen as ANT task. Ant's taskdef itself giving me lots of class not found exception. Every first time it gave class not fount for "com.sun.tools.ws.ant.WsGen" then added "jaxws-tools-2.1.7.jar" in class path. After this , it gave class not found for "com/sun/istack/tools/ProtectedTask" then added "istack-commons-tools-2.7.jar". Now it's giving class not found for "com/sun/tools/xjc/api/util/ToolsJarNotFoundException"

I am sure , I am not following right path.

here is build.xml

<?xml version="1.0"?>
<project name="Application Services" basedir="." default="compile">
<property file="build.properties"/>
<path id="external.projects">

    <fileset dir="/scratch/softwares" includes="*.jar"/>

</path>

<taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen" classpathref="external.projects"> 

</taskdef>


<target name="compile" depends="clean,init">

      <javac destdir="${build.dir}" srcdir="${src.dir}" classpathref="external.projects"/>
</target>
<target name="packaging" depends="compile">
    <mkdir dir="${jar.dir}"/>
    <jar destfile="${jar.dir}/application.services.jar" basedir="${build.dir}"/>
    <wsgen 
        sei="webservice.interfaces.student.IStudentApplicationService"
        destdir="${jar.dir}" cp="external.projects" resourcedestdir="${jar.dir}"
        sourcedestdir="${jar.dir}" genwsdl="true"
        />
</target>
</project>

2 Answers 2

1

Debugging dependencies between jars can drive you demented......What your ANT project requires is a dependency manager, for example Apache ivy.

A second problem I noticed is that you're running a very old version is jaxws-tools, released in 2009. Since then there have been lots and lots of updates.

Example

Demonstrates how ivy can be used to create a managed classpath for the wsgen task.

<ivy:cachepath pathid="wsgen.path">
  <dependency org="com.sun.xml.ws" name="jaxws-tools" rev="2.2.10" />
</ivy:cachepath>

<taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen" classpathref="wsgen.path"/> 

build.xml

<?xml version="1.0"?>
<project name="Application Services" basedir="." default="packaging" xmlns:ivy="antlib:org.apache.ivy.ant">

  <available classname="org.apache.ivy.Main" property="ivy.installed"/> 

  <target name="install-ivy" description="Install ivy" unless="ivy.installed">
    <mkdir dir="${user.home}/.ant/lib"/>
    <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar"/>
    <fail message="Ivy has been installed. Run the build again"/>
  </target>

  <target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
    <ivy:cachepath pathid="wsgen.path">
      <dependency org="com.sun.xml.ws" name="jaxws-tools" rev="2.2.10" />
    </ivy:cachepath>
  </target>

  <target name="packaging" depends="resolve">
    <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen" classpathref="wsgen.path"/> 

    <wsgen 
        sei="webservice.interfaces.student.IStudentApplicationService"
        destdir="${jar.dir}" cp="external.projects" resourcedestdir="${jar.dir}"
        sourcedestdir="${jar.dir}" genwsdl="true"
        />
  </target>

</project>

Notes:

  • This build file will automatically install the ivy plugin
  • Dependencies are automatically downloaded and cached within the "resolve" target.
0

Complete build.xml with ivy...

<?xml version="1.0"?>
<project name="Application Services" basedir="." default="compile" xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="build.properties"/>
<path id="external.projects">
    <fileset dir="../xface.dto/${jar.dir}" includes="*.jar"/>
    <fileset dir="../webservice.interfaces/${jar.dir}" includes="*.jar"/>

</path>
<available classname="org.apache.ivy.Main" property="ivy.installed"/> 




<target name="info">
      <echo>Apache Ant!</echo>
   </target>
<target name="clean">
    <echo>cleaning....</echo>  
    <delete dir="${build.dir}"/>
    <delete dir="${jar.dir}"/>
   </target>
<target name="init">
    <echo>init....</echo>  
      <mkdir dir="${build.dir}"/>
   </target>
<target name="compile" depends="clean,init">
    <echo>compiling....</echo>  
      <javac destdir="${build.dir}" srcdir="${src.dir}" classpathref="external.projects"/>
</target>
<target name="install-ivy" unless="ivy.installed">
    <echo>installing ivy....</echo>
    <mkdire dir="${user.home}/.ant/lib"/>
    <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar" />
    <fail message="Ivy has been installed. Run the build again"/>
</target>
<target name="resolve" depends="install-ivy">
    <ivy:cachepath pathid="wsgen.path">
        <dependency org="com.sun.xml.ws" name="jaxws-tools" rev="2.2.10" />
    </ivy:cachepath>
</target>
<target name="packaging" depends="compile,resolve">
    <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen" classpathref="wsgen.path"/> 
    <mkdir dir="${jar.dir}"/>
    <jar destfile="${jar.dir}/application.services.jar" basedir="${build.dir}"/>
    <wsgen 
        sei="application.services.student.StudentApplicationService"
        destdir="${jar.dir}"  resourcedestdir="${jar.dir}"
        sourcedestdir="${jar.dir}" genwsdl="true"
        >

            <classpath>
                <fileset dir="../xface.dto/${jar.dir}" includes="*.jar"/>
                <fileset dir="../webservice.interfaces/${jar.dir}" includes="*.jar"/>
                <pathelement location="./bin"/>
            </classpath>



    </wsgen>
</target>
</project>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.