简体   繁体   English

taskdef 类 com.sun.tools.ws.ant.WsImport 无法在“Java Web 服务教程”之后找到

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

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 The java web services tutorial , which seems at points out of sync,我想要做的(更大的图景)是通过The java web services tutorial ,它似乎不同步,

Specially here , when I try to compile, I get the following message:特别是在这里,当我尝试编译时,我收到以下消息:

C:\\javaeetutorial5\\examples\\jaxws\\common\\targets.xml:26: taskdef class com.sun.tools.ws.ant.WsImport cannot be found C:\\javaeetutorial5\\examples\\jaxws\\common\\targets.xml:26: 找不到 taskdef 类com.sun.tools.ws.ant.WsImport

I have tried many different combinations of placing jars or changing environment variables, but with no result.我尝试了许多不同的放置 jar 或更改环境变量的组合,但没有结果。 Any successful stories?有什么成功的案例吗?

The full build error message is the following:完整的构建错误消息如下:

BUILD FAILED构建失败

C:\\javaeetutorial5\\examples\\jaxws\\helloservice\\build.xml:4: The following error occurred while executing this line: C:\\javaeetutorial5\\examples\\jaxws\\helloservice\\build.xml:4: 执行此行时出现以下错误:

C:\\javaeetutorial5\\examples\\jaxws\\common\\targets.xml:26: taskdef A class needed by class com.sun.tools.ws.ant.WsImport cannot be found: org/apache/tools/ant/DynamicConfigurator C:\\javaeetutorial5\\examples\\jaxws\\common\\targets.xml:26: taskdef 找不到类 com.sun.tools.ws.ant.WsImport 所需的类:org/apache/tools/ant/DynamicConfigurator

using the classloader AntClassLoader[C:\\Program Files (x86)\\Java\\jdk1.6.0_23\\lib\\tools.jar]使用类加载器 AntClassLoader[C:\\Program Files (x86)\\Java\\jdk1.6.0_23\\lib\\tools.jar]

Total time: 0 seconds总时间:0秒

And the corresponding taskdef :以及相应的taskdef

<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
    <classpath refid="jaxws.classpath"/>
</taskdef>

Also a peek into the endorsement directory:还可以查看背书目录:

C:\javaeetutorial5\kschneid>cd %JAVA_HOME%

C:\Program Files (x86)\Java\jdk1.6.0_23>dir lib\endorsed
 Volume in drive C is OSDisk
 Volume Serial Number is AAAA-BBBB

 Directory of C:\Program Files (x86)\Java\jdk1.6.0_23\lib\endorsed

25/02/2011  09:34    <DIR>          .
25/02/2011  09:34    <DIR>          ..
25/02/2011  09:34           105,134 jaxb-api.jar
25/02/2011  09:33            54,476 jaxws-api.jar
               2 File(s)        159,610 bytes
               2 Dir(s)  110,907,056,128 bytes free

C:\Program Files (x86)\Java\jdk1.6.0_23>

You can fix the problem in Netbeans xy as follows:您可以按如下方式修复 Netbeans xy 中的问题:

  1. Go to Tools->Options->Java->Ant.转到工具->选项->Java->Ant。
  2. Click on "Add JAR/ZIP..." under the Classpath section单击“类路径”部分下的“添加 JAR/ZIP...”
  3. Navigate to "C:\\Program Files\\NetBeans xy\\enterprise\\modules\\ext\\metro\\"导航到“C:\\Program Files\\NetBeans xy\\enterprise\\modules\\ext\\metro\\”
  4. Select all files.选择所有文件。
  5. Click OK, and try the import/regenerate again.单击“确定”,然后再次尝试导入/重新生成。

where xy = 7.1, 7.2, 8.0 etc其中 xy = 7.1、7.2、8.0 等

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.问题是由于相关的jaxws jar 不在类路径中,请参见上面的 pathelement 节点。 Adding the jar to the classpath resolves the issue.将 jar 添加到类路径可以解决问题。

The <wsimport> ant task is not included in the JDK, even though there is a wsimport.exe which does exactly the same. <wsimport> ant 任务不包含在 JDK 中,即使有一个 wsimport.exe 完全相同。

If you really want the ant task, you can download jaxws-ri and use the 23(!) jars in the lib folder.如果你真的想要 ant 任务,你可以下载 jaxws-ri 并使用 lib 文件夹中的 23(!) jars。

Or you can use this workaround by calling wsimport.exe :或者您可以通过调用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>

I fully support non-IDE development, especially when trying to learn something ;).我完全支持非 IDE 开发,尤其是在尝试学习某些东西时 ;)。 Try starting with this simple build file (use the actual location of your JAX-WS RI install):尝试从这个简单的构建文件开始(使用 JAX-WS RI 安装的实际位置):

<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:如果您只运行ant ,您应该会看到如下输出:

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" .由于看起来您使用的是 Java 6,因此请注意“在 JDK6 上运行”

我将classname="com.sun.tools.ws.ant.WsImport"更改为classname="com.sun.tools.ws.WsImport" ,这为我解决了这个问题。

This worked for me:这对我有用:

I download the JAVA-WS library from official site I put it on extra-lib directory.我从官方网站下载了 JAVA-WS 库,我把它放在了 extra-lib 目录中。 This directory is on the same level of build.xml.该目录与 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:在 build.xml 上,我从 jaxws-build.xml 复制名为“wsimport-init”的 Ant 任务,并按照以下模式修改它:

...
    <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/参考: http : //www.staniscia.net/989-resolve-the-portable-problem-of-netbean-jax-ws-libraries-for-web-service-clients/

要解决此错误,我们需要使用工具->选项,单击杂项,然后在 Ant 选项卡中使用添加 Jar/ZIP 在目录中找到并添加库webservices-tools.jarwebservices-rt.jar

I had the same problem after testing Netbeans 11 and then going back to Netbeans 8.2.在测试 Netbeans 11 然后回到 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".对于某些项目,Netbeans 会弹出一个对话框“项目 ProjectName 使用来自另一个 Netbeans 安装的build.properties ”,然后单击“使用此安装”。

Better still, you can use the command line tool wsimport to generate the jar or files更好的是,您可以使用命令行工具 wsimport 生成 jar 或文件

http://docs.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html 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将文件生成到 build/classes 文件夹中,然后您可以从那里使用 ant javac 引用它

If you are using Eclipse IDE and facing this issue, here is something that worked for me.如果您正在使用 Eclipse IDE 并遇到这个问题,这里有一些对我有用的东西。 Go to : Window > Preferences.转到:窗口 > 首选项。 Find the Ant option on the left side.找到左侧的 Ant 选项。

Expand it and you will find ANT Runtime.展开它,您将找到 ANT Runtime。 Select that option and check the jars included in the Classpath tab.选择该选项并检查 Classpath 选项卡中包含的 jar。

Select the Add External Jar's option.选择添加外部 Jar 的选项。 Now go to the ant home folder in your system.现在转到系统中的 ant 主文件夹。 Go to the lib folder and add all the jars / missing jar files.转到 lib 文件夹并添加所有 jars/缺少的 jar 文件。

this will resolve the missing dependency for ant-build.这将解决 ant-build 缺少的依赖项。

Hope That Helps!希望有帮助!

I found an answer which does not satisfy me at all: Installed netbeans which takes care of joining things together.我找到了一个完全不满足我的答案:安装了负责将事物连接在一起的 netbeans。 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?)我可以跟进教程,但我仍然认为一切都应该从命令行完成(我的饮食中是否有太多 Unix?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到taskdef类com.sun.javacard.ant.tasks.ConverterTask - taskdef class com.sun.javacard.ant.tasks.ConverterTask cannot be found 找不到com.sun.xml.rpc.tools.ant.Wscompile - com.sun.xml.rpc.tools.ant.Wscompile cannot be found 找不到taskdef类org.apache.tools.ant.taskdefs.optional.junit.JUnitTask - taskdef class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found Ant Build - 找不到任务定义 - Ant Build - taskdef cannot be found 找不到taskdef ant任务 - The taskdef ant task cannot be found Java 和 ProGuard - taskdef class proguard.ant.ProGuardTask 无法使用类加载器 AntClassLoader 找到 - Java and ProGuard - taskdef class proguard.ant.ProGuardTask cannot be found using the classloader AntClassLoader 找不到taskdef类org.apache.catalina.ant.InstallTask - taskdef class org.apache.catalina.ant.InstallTask cannot be found 使用classloader AntClassLoader []无法找到ant taskdef类 - ant taskdef class cannot be found using the classloader AntClassLoader[] 在 NetBeans 9 和 11 中打包为 DMG 图像,JDK 11 返回“typedef class com.sun.javafx.tools.ant.FXJar cannot be found using the..” - Package as DMG Image in NetBeans 9 & 11, JDK 11 returns "typedef class com.sun.javafx.tools.ant.FXJar cannot be found using the.." java soap Web服务.wsimport - java soap web services .wsimport
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM