获取错误“;提供商com.sun.org.apache.xerces.internal.axp.DocumentBuil

本文关键字:xerces apache internal axp DocumentBuil org sun 取错误 提供商 com 获取 | 更新日期: 2023-09-27 18:21:17

我正在C#中构建一个应用程序,该应用程序使用com.gargoylesoftware.htmlunit.WebClient访问和检索网页中的信息。

我的应用程序在主项目中运行良好,但当我试图构建单元测试来测试项目类时,我会遇到以下错误:

FactoryConfigurationError
Message "Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found"
Source  "IKVM.OpenJDK.XML.API"  string
StackTrace  "   at javax.xml.parsers.DocumentBuilderFactory.newInstance()
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.loadConfiguration(Reader configurationReader)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.loadConfiguration()
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration..ctor(BrowserVersion )
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(BrowserVersion browserVersion)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine..ctor(WebClient webClient)
at com.gargoylesoftware.htmlunit.WebClient.init(BrowserVersion , ProxyConfig )
at com.gargoylesoftware.htmlunit.WebClient..ctor(BrowserVersion browserVersion)
at com.gargoylesoftware.htmlunit.WebClient..ctor()
at GWT.HeadlessBrowser..ctor() in C:''hg''EXE''GWT''HeadlessBrowser.cs:line 57
at TestGWT.ProgramTest.TestLogInProcessForGWT() in C:''hg''TestGWT''ProgramTest.cs:line 115"

尝试在单元测试类中创建HtmlUnitWebClient也会导致此错误。

我在主项目和包含单元测试的项目中都有项目引用htmlunit-2.7、IKVM.OpenJDK.Core和IKVM.OopenJDK.XML.API。

我是否需要一个额外的项目参考来运行单元测试?是什么原因导致了这个错误?

该测试类使用Microsoft.VisualStudio.TestTools.UnitTesting;

获取错误“;提供商com.sun.org.apache.xerces.internal.axp.DocumentBuil

我最近在测试同一个库时遇到了同样的问题。我发现包含对IKVM.OpenJDK.XML.Parse.dll的引用解决了这个问题。

我遇到了类似的问题。

com.sun.org.apache.xerces.internal.axp.DocumentBuilderFactoryImpl类似乎没有加载,因此工厂无法创建它。在调用工厂之前添加此行将强制加载程序集,然后工厂可以看到它,一切都按预期工作。。。

com.sun.org.apache.xerces.@internal.jaxp.SAXParserFactoryImpl s =   new  com.sun.org.apache.xerces.@internal.jaxp.SAXParserFactoryImpl();