taskdef class com.sun.tools.ws.ant.WsImport cannot be found Following “The java web services tutorial”

后端 未结 11 1452
梦毁少年i
梦毁少年i 2021-02-02 15:50

I saw the same issue in many different locations and even after a good portion of googling, I could not resolve it. What I am trying to do (the bigger picture) is to go through

相关标签:
11条回答
  • 2021-02-02 16:04

    The <wsimport> ant task is not included in the JDK, even though there is a wsimport.exe which does exactly the same.

    If you really want the ant task, you can download jaxws-ri and use the 23(!) jars in the lib folder.

    Or you can use this workaround by calling wsimport.exe:

    <target name="generate-client" >
        <exec executable="${java.home}/../bin/wsimport">
            <arg line="-keep -d build/classes -p ebay.apis -s src -wsdllocation http://localhost:7070/Ebay?wsdl eBaySvc.wsdl"/>
        </exec>
    </target>
    
    0 讨论(0)
  • 2021-02-02 16:08

    I found an answer which does not satisfy me at all: Installed netbeans which takes care of joining things together. Still the command line does not work (so that means that it is compartmentalised the environment which is good). I can follow up the tutorial, but I still believe that everything should be done from the command line (was there too much Unix in my diet?)

    0 讨论(0)
  • 2021-02-02 16:11

    Better still, you can use the command line tool wsimport to generate the jar or files

    http://docs.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html

    generate the files into the build/classes folder, you can then reference it from there with ant javac

    0 讨论(0)
  • 2021-02-02 16:14

    This worked for me:

    I download the JAVA-WS library from official site I put it on extra-lib directory. This directory is on the same level of build.xml. On build.xml I copy from jaxws-build.xml the Ant task named “wsimport-init” and I modify it as in the follow mode:

    ...
        <target name="wsimport-init" depends="init">
            <mkdir dir="${build.generated.sources.dir}/jax-ws"/>
            <taskdef name="wsimport" classname="com.sun.tools.ws.Ant.WsImport">
                <classpath>
                    <fileset dir="./extra-lib">
                        <include name="**/*.jar"/>
                    </fileset>
                </classpath>
            </taskdef>
        </target>
    ...
    

    Reference: http://www.staniscia.net/989-resolve-the-portable-problem-of-netbean-jax-ws-libraries-for-web-service-clients/

    0 讨论(0)
  • 2021-02-02 16:18

    If you are using Eclipse IDE and facing this issue, here is something that worked for me. Go to : Window > Preferences. Find the Ant option on the left side.

    Expand it and you will find ANT Runtime. Select that option and check the jars included in the Classpath tab.

    Select the Add External Jar's option. Now go to the ant home folder in your system. Go to the lib folder and add all the jars / missing jar files.

    this will resolve the missing dependency for ant-build.

    Hope That Helps!

    0 讨论(0)
提交回复
热议问题