Java 在 GWT 中导入 Gears API 时找不到 org.apache.xerces.jaxp.SAXParserFactoryImpl

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1016286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:19:01  来源:igfitidea点击:

org.apache.xerces.jaxp.SAXParserFactoryImpl not found when importing Gears API in GWT

javagwtxerces

提问by Templar

I've created a GWTproject using Eclipse which was working perfectly (I was able to run it in both Hosted Mode and on Google App Engine) until I tried to import the Gears API for Google Web Toolkit. After adding the following line to my java source file:

我已经使用 Eclipse创建了一个GWT项目,该项目运行良好(我能够在托管模式和 Google App Engine 上运行它),直到我尝试为 Google Web Toolkit导入Gears API。将以下行添加到我的 java 源文件后:

import com.google.gwt.gears.client.geolocation.Geolocation;

I get the following error when I try to compile:

当我尝试编译时出现以下错误:

19-Jun-2009 3:36:09 AM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed com.google.apphosting.utils.jetty.DevAppEngineWebAppContext@1c7d682{/,C:\Documents and Settings\Geoff Denning\workspace\TaskPath\war}
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found

I've already added the gwt-gears.jar file to my \war\WEB-INF\lib directory, and I've referenced it in Eclipse as follows:

我已经将 gwt-gears.jar 文件添加到我的 \war\WEB-INF\lib 目录中,并且我已经在 Eclipse 中引用了它,如下所示:

Java Build Path in Eclipse

Eclipse 中的 Java 构建路径

I've even opened the gwt-gears.jar file and confirmed that org/apache/xerces/jaxp/SAXParserFactoryImpl.class does exist. Can anyone give me any pointers as to why I'm getting the above error?

我什至打开了 gwt-gears.jar 文件并确认 org/apache/xerces/jaxp/SAXParserFactoryImpl.class 确实存在。谁能给我任何关于为什么我收到上述错误的提示?

采纳答案by Templar

Apparently this is a bug in jre 1.5. I was able to resolve the problem by switching my default JRE in Eclipse from 1.5.0_06 to 1.6.0_03, as shown below:

显然这是 jre 1.5 中的一个错误。我能够通过将 Eclipse 中的默认 JRE 从 1.5.0_06 切换到 1.6.0_03 来解决该问题,如下所示:

Eclipse Installed JREs

Eclipse 安装的 JRE

Thanks to Jonand Rahulfor pointing me in the right direction.

感谢JonRahul为我指明了正确的方向。

回答by Jon

Check that Xerces exists in:

检查 Xerces 是否存在于:

$JAVA_HOME/lib/endorsed

Sounds like a Java 5 issue. Also check the Java system property for:

听起来像是 Java 5 问题。还要检查 Java 系统属性:

javax.xml.parsers.SAXParserFactory

It should be:

它应该是:

org.apache.xerces.jaxp.SAXParserFactoryImpl

If not then that's your issue, make sure you set the system property.

如果不是,那就是你的问题,确保你设置了系统属性。

回答by Roland

This happened to me. I had conflicting JARs in my workspace. I removed one and boom it worked. The message didn't lend very well to the root of the error.

这发生在我身上。我的工作区中有冲突的 JAR。我删除了一个并繁荣它起作用了。该消息并没有很好地说明错误的根源。

回答by Alex

My SAXParserFactoryImpl problemwas caused by gwt-gadgets.jar I had in my boot class path. Removing this JAR from the boot class path solved the problem for me. Basically you have to remove any JAR containing a SAXParserFactoryImpl class from your build path (user libs).

我的SAXParserFactoryImpl 问题是由我的引导类路径中的 gwt-gadgets.jar 引起的。从引导类路径中删除这个 JAR 为我解决了这个问题。基本上,您必须从构建路径(用户库)中删除任何包含 SAXParserFactoryImpl 类的 JAR

回答by Isaiah

Remove the $JAVA_HOME/jre/lib/jaxp.properties fixed the issue.

删除 $JAVA_HOME/jre/lib/jaxp.properties 修复了该问题。

回答by Todd Url

Take a look at Trouble with Selenium (XercesImpl) and Google App Engine. I had a similar problem with GWT / GAE (SAXParserFactoyImpl not found) and solved it by;

看看Selenium (XercesImpl) 和 Google App Engine 的麻烦。我在 GWT / GAE 上遇到了类似的问题(未找到 SAXParserFactoyImpl)并通过以下方式解决了它;

  1. Importing the jar to war/WEB-INF/lib
  2. Adding the jar to the build path
  1. 将 jar 导入到 war/WEB-INF/lib
  2. 将 jar 添加到构建路径