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

后端 未结 11 1450
梦毁少年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 15:56

    You can fix the problem in Netbeans x.y as follows:

    1. Go to Tools->Options->Java->Ant.
    2. Click on "Add JAR/ZIP..." under the Classpath section
    3. Navigate to "C:\Program Files\NetBeans x.y\enterprise\modules\ext\metro\"
    4. Select all files.
    5. Click OK, and try the import/regenerate again.

    where x.y = 7.1, 7.2, 8.0 etc

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

    Well, apparently a link to a website with the solution to this issue is unacceptable, so I'll paste the answer here:

    <property name="BUILD_LIBS" location="C:/Projects/Build/Libs/" />
    
    <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
        <classpath>
            <pathelement location="${BUILD_LIBS}/jaxws-ri/lib/jaxws-tools.jar"/>
        </classpath>
    </taskdef>
    

    The issue is due to the relevant jaxws jar not being in the class path see the pathelement node above. Adding the jar to the classpath resolves the issue.

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

    I fully support non-IDE development, especially when trying to learn something ;). Try starting with this simple build file (use the actual location of your JAX-WS RI install):

    <project name="jaxws-tutorial" default="wsimport">
    
        <property name="jaxws.home" location="D:/jaxws-ri-2_2_1"/>
    
        <path id="wsimport.classpath">
            <fileset dir="${jaxws.home}/lib" includes="jaxws-tools.jar"/>
        </path>
    
        <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport" classpathref="wsimport.classpath"/>
    
        <target name="wsimport">
            <wsimport>
                <arg value="-version"/>
            </wsimport>
        </target>
    
    </project>
    

    If you just run ant, you should see some output like the following:

    wsimport:
     [wsimport] Consider using <depends>/<produces> so that wsimport won't do unnecessary compilation
     [wsimport] JAX-WS RI 2.2.1-b01-
    

    Since it looks like you're using Java 6, pay attention to "Running on JDK6".

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

    I had the same problem after testing Netbeans 11 and then going back to Netbeans 8.2. The solution was the file

    ProjectName\nbproject\private\private.properties
    

    that one had an entry

    user.properties.file=XXXX\\AppData\\Roaming\\NetBeans\\11.0\\build.properties
    

    changing it back to the correct installation

    user.properties.file=XXXX\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
    

    solved the problem. For some projects Netbeans popped up a dialogbox "The project ProjectName uses build.properties from another Netbeans installation", then click "Use this installation".

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

    To get past this error we need to use Tools->Options, click Miscellaneous, and in the Ant tab use Add Jar/ZIP to locate and add the libraries webservices-tools.jar and webservices-rt.jar in the directory

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

    I changed the classname="com.sun.tools.ws.ant.WsImport" to classname="com.sun.tools.ws.WsImport", which fixed this issue for me.

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