Problem-failed to create task or type xjc

Problem-failed to create task or type xjc

Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.

Answer: If you are trying to create web service client and using ant build task to create wsdl client using XJC tool which comes with JDK distribution then you will have to add taskdef of it as sample shown below:

<project name="SpringWebserviceTemplate" default="generate.client.bindings" basedir="." >
    <description>Generate web service client using spring WS template</description>
    <property name="root" value="." />
    <property name="lib"  location="${root}/lib"/>  
    <path id="classpathid_location">
            <fileset dir="${lib}/main" includes="*.jar"/>
    <!-- -->
    <taskdef name="xjc" classname="">
        <classpath refid="classpathid_location"/>

    <!--    Generate Targets to generate wsdl client -->
        <target name="generate.client.bindings" description="- -> Generate XML binding artifacts" >
                    <!-- -->       
                    <xjc    destdir="${basedir}/src" 
                        <arg value="-verbose" />
                        <arg value="-wsdl" />
                        <arg value="${basedir}/conf/xml/wsdl/currencyConvertor.wsdl" />
        <!--    Compile Targets     -->


Please note exception will be thrown if taskdef is missing form build file.

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *