Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant 为什么TestNG会抛出一个;javax.xml.parsers.parserConfiguration异常:不支持验证";错误_Ant_Xml Parsing_Testng - Fatal编程技术网

Ant 为什么TestNG会抛出一个;javax.xml.parsers.parserConfiguration异常:不支持验证";错误

Ant 为什么TestNG会抛出一个;javax.xml.parsers.parserConfiguration异常:不支持验证";错误,ant,xml-parsing,testng,Ant,Xml Parsing,Testng,在将TestNG的实现从6.11升级到6.13.1之后,我遇到了一个错误。我有一个ANT构建(尝试了Ant1.9.4和1.10.1上的构建,但失败相同),它触发了一个包含一个类的TestNG套件。在完成所有ANT设置之后,它调用TestNG开始测试执行,我立即得到以下错误: [testng] javax.xml.parsers.ParserConfigurationException: validation is not supported [testng] at org.gjt.xpp.

在将TestNG的实现从6.11升级到6.13.1之后,我遇到了一个错误。我有一个ANT构建(尝试了Ant1.9.4和1.10.1上的构建,但失败相同),它触发了一个包含一个类的TestNG套件。在完成所有ANT设置之后,它调用TestNG开始测试执行,我立即得到以下错误:

[testng] javax.xml.parsers.ParserConfigurationException: validation is not supported
[testng]    at org.gjt.xpp.jaxp11.SAXParserFactoryImpl.newSAXParser(SAXParserFactoryImpl.java:100)
[testng]    at org.testng.xml.XMLParser.<clinit>(XMLParser.java:29)
[testng]    at org.testng.xml.Parser.<clinit>(Parser.java:34)
[testng]    at org.testng.TestNG.parseSuite(TestNG.java:290)
[testng]    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:334)
[testng]    at org.testng.TestNG.initializeEverything(TestNG.java:974)
[testng]    at org.testng.TestNG.run(TestNG.java:988)
[testng]    at org.testng.TestNG.privateMain(TestNG.java:1330)
[testng]    at org.testng.TestNG.main(TestNG.java:1299)
[testng] [TestNG] [ERROR] java.lang.NullPointerException
[testng] Exception in thread "main" java.lang.NullPointerException
[testng]    at org.testng.TestNG.getStatus(TestNG.java:206)
[testng]    at org.testng.TestNG.main(TestNG.java:1300)
[testng] The tests failed.
[testng]javax.xml.parsers.parserConfiguration异常:不支持验证
[testng]位于org.gjt.xpp.jaxp11.saxparserfactorympl.newSAXParser(saxparserfactorympl.java:100)
[testng]位于org.testng.xml.XMLParser(XMLParser.java:29)
[testng]位于org.testng.xml.Parser(Parser.java:34)
[testng]位于org.testng.testng.parseSuite(testng.java:290)
[testng]位于org.testng.testng.initializeSuitesAndJarFile(testng.java:334)
[testng]位于org.testng.testng.initializeEverything(testng.java:974)
[testng]位于org.testng.testng.run(testng.java:988)
[testng]位于org.testng.testng.privateMain(testng.java:1330)
[testng]位于org.testng.testng.main(testng.java:1299)
[testng][testng][ERROR]java.lang.NullPointerException
线程“main”java.lang.NullPointerException中的[testng]异常
[testng]位于org.testng.testng.getStatus(testng.java:206)
[testng]位于org.testng.testng.main(testng.java:1300)
[testng]测试失败。
以下是我的build.xml:

<project name="6 - GW Testing" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="lib.dir" location="C:/dev/.ivy2/cache" />
<property name="res.dir" location="../TestNGReports" />
<property name="GWPersistence.ivy.file" value="C:/tmp/svncheckouts/guidewire/GWPersistenceIvy/gwpersistence-ivy.xml"/>
<property name="GWBroker.ivy.file" value="C:/tmp/svncheckouts/guidewire/GWBrokerIvy/gwbroker-ivy.xml"/>
<property name="GWRepository.ivy.file" value="C:/tmp/svncheckouts/guidewire/GWRepositoryIvy/gwrepository-ivy.xml"/>
<property name="GWServices.ivy.file" value="C:/tmp/svncheckouts/guidewire/GWServicesIvy/gwservices-ivy.xml"/>
<property name="GWTesting.ivy.file" value="C:/tmp/svncheckouts/guidewire/GWTestingIvy/gwtesting-ivy.xml"/>
<property name="Local.config" location="C:/tmp/regression-configs/guidewire" />
<property name="Regression.config" location="${Local.config}/suite" />

<path id="lib.classpath">
    <fileset dir="${lib.dir}">
        <include name="**/*.jar" />
    </fileset>
</path>

<path id="combined.classpath">
    <path refid="lib.classpath" />
</path>

<target name="init" description="initialize the build environment">
    <tstamp />

    <delete dir="${res.dir}" />
    <mkdir dir="${res.dir}" />

    <delete dir="C:/Users/qauser/.ivy2/cache/com.idfbins.guidewire" />
</target>

<target name="resolve" depends="init" description="retrieve dependencies with ivy">
    <ivy:configure file="C:/dev/.ivy2/ivysettings.xml" />

    <ivy:resolve file="${GWPersistence.ivy.file}" />
    <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]" />

    <ivy:resolve file="${GWBroker.ivy.file}" />
    <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]" />

    <ivy:resolve file="${GWRepository.ivy.file}" />
    <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]" />

    <ivy:resolve file="${GWServices.ivy.file}" />
    <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]" />

    <ivy:resolve file="${GWTesting.ivy.file}" />
    <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]" />

    <ivy:resolve file="../GWRepositoryConfig/suite/ivy.xml" />
    <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[type]-[revision].[ext]" />
</target>

<target name="run-tests-a-test-runner" depends="resolve">
    <taskdef name="testng" classpathref="lib.classpath" classname="org.testng.TestNGAntTask">
        <classpath>
            <pathelement location="../../lib/default/testng-6.11.jar"/>
        </classpath>
    </taskdef>

    <delete file="${Local.config}/config.properties" />
    <copy file="C:/tmp/svncheckouts/guidewire/GWRepositoryConfig/suite/regression-test-runner.properties" todir="${Local.config}" />
    <rename src="${Local.config}/regression-test-runner.properties" dest="${Local.config}/config.properties"/>
    <echo message="CONFIG FILE: regression-test-runner.properties copied to config.properties" />

    <echo message="Running Tests..." />
    <testng classpathref="combined.classpath" outputDir="${res.dir}" haltOnfailure="false">
        <classpath location="combined.classpath" />
        <xmlfileset dir="C:/tmp/svncheckouts/guidewire/JobXMLFiles" includes="a-test-runner.xml"/>
    </testng>
  </target>
</project>

这是我的套房声明:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="A-Test-Runner" verbose="1">
<test name="A-Test-Runner">
    <classes>
        <class name="regression.r2.clock.billingcenter.cancel.TestCancellationOnBoundPolicy" />
    </classes>
</test>


到目前为止,我已经尝试删除套件声明中的DTD,我已经改变了各个方向的路径,并尝试了各种版本的ANT和TestNG。到目前为止,我唯一能够开始工作的就是恢复到TestNG 6.11。我不知道这里发生了什么事。有什么想法吗?

看起来您的类路径正在将您解析为导致此问题的外部解析器。我想你可能已经下定决心了

我这么说是因为我明白了

位于org.gjt.xpp.jaxp11.saxparserfactorympl.newSAXParser(saxparserfactorympl.java:100)

你例外

您可以通过以下方式尝试克服这一问题:通过以下方式指定默认解析器,迫使Java退回到JDK中可用的默认解析器


-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.saxparserfactorympl

谢谢!你给我指明了正确的方向。原来Hibernate给我们带来了麻烦。修复方法是排除它附带的dom4jjjar,并包括一个更新的版本。直到深入研究,我才意识到,Ivy中的org声明在某种程度上改变了dom4j,因此我们使用的是dom4j的旧版本(大约2007年)。这个罐子里装的是xpp3。更新到新的dom4j模块(从2017年9月起)为我们完美地修复了它。我仍然认为它使用的是xpp3,但它现在能够解析我的xml文件。再次感谢你。你是救命恩人!事实上,你自己的评论应该是正确的答案。在我们的例子中,它是由dom4j拉取的拉取解析器依赖项。Ofc@Krishnan Mahadevan的答案是合法的,但若应用程序中并没有使用外部解析器,那个么应该通过根本原因来解决