【问题标题】:Java Problems when Running Ant: noclassdef运行 Ant 时的 Java 问题:noclassdef
【发布时间】:2013-05-01 21:06:27
【问题描述】:

Windows 7、Java jdk1.6.0_32、Ant 1.9

用户和系统变量:

JAVA_HOME:C:\Program Files\Java\jdk1.6.0_32

路径:C:\Program Files\Java\jdk1.6.0_32;c:\ant\bin;

ANT_HOME:c:\ANT

Run command prompt as administrator
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

H:\>c:

C:\>w:

W:\>cd webadvisor

W:\WebAdvisor>cd wasql*

W:\WebAdvisor\WASQLTEST3>c:\ant\bin\ant
Buildfile: W:\WebAdvisor\WASQLTEST3\build.xml

init:

prepare:
 [echo] Preparing Update...
 [copy] Copying 208 files to W:\WebAdvisor\WASQLTEST3\temp
 [copy] Copying 129 files to W:\WebAdvisor\WASQLTEST3\temp
 [copy] Copying 49 files to W:\WebAdvisor\WASQLTEST3\temp

splitdocs:

merge-cleanup:
[delete] Deleting: W:\WebAdvisor\WASQLTEST3\custom\WEB-INF\web.xml

findwebxml:

merge:

datatelxmloverride:

mergeDefault:

BUILD FAILED
W:\WebAdvisor\WASQLTEST3\build.xml:112: The following error occurred while executing this line:
W:\WebAdvisor\WASQLTEST3\build.xml:165: The following error occurred while executing this line:
W:\WebAdvisor\WASQLTEST3\build.xml:173: java.lang.NoClassDefFoundError: org/apache/xml/serialize/OutputFormat
        at org.codehaus.cargo.module.webapp.WebXmlIo.writeWebXml(WebXmlIo.java:256)
        at org.codehaus.cargo.module.webapp.WebXmlIo.writeWebXml(WebXmlIo.java:225)
        at org.apache.cactus.integration.ant.WebXmlMergeTask.execute(WebXmlMergeTask.java:120)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at 

【问题讨论】:

    标签: java ant command-line


    【解决方案1】:

    org/apache/xml/serialize/OutputFormat 是一个 Xerces 类...在您的系统中搜索 xerces*.jar。这个文件存在吗?它在你的类路径中吗?

    【讨论】:

    • 我找到了一个名为 xercesImpl-2.6.2.jar 的文件,并将其放入 c:\CLASSPATH=.;C:\xercesImpl-2.6.2.jar;我还需要做什么?
    【解决方案2】:

    您的类路径缺少

    所需的 jar
    org/apache/xml/serialize/OutputFormat
    

    检查你的类路径中是否有xercesImpl.jar

    编辑

    您可以通过在 ant 编译目标中包含所需的 jar 并将所有所需的 jar 放入 lib 文件夹中来设置。

    <target name="compile" depends=""   description="compile the java source files">  
     <javac srcdir="." destdir="${build}">  
        <classpath>  
            <fileset dir="${lib}">  
                <include name="**/*.jar" />  
            </fileset>  
        </classpath>  
    </javac>  
    

    【讨论】:

    • 我找到了一个名为 xercesImpl-2.6.2.jar 的文件,并将其放入 c:\CLASSPATH=.;C:\xercesImpl-2.6.2.jar;我还需要做什么?
    • 然后在 ant 编译类路径中包含。编辑了答案
    • 包含在 antlib 文件夹中,它就像魔术一样工作。谢谢@nullpointerexception
    猜你喜欢
    • 1970-01-01
    • 2015-10-05
    • 2011-10-07
    • 1970-01-01
    • 2013-07-05
    • 1970-01-01
    • 1970-01-01
    • 2017-04-13
    • 1970-01-01
    相关资源
    最近更新 更多