在 Eclipse 动态 Web 项目中使用 JSF 时 Tomcat 中抛出异常
我正在尝试在 MacOSX 上的 Eclipse (Indigo SR1) 中设置一个 Web 项目: 雄猫7.0.22 JSF 2.0
这是一个动态 Web 项目,我通过项目属性添加了 JSF 项目方面。
添加 JSF Project Facet 时,我可以选择使用:Mojarra 2.0.3 或 Apache MyFaces 2.0.2
如果我选择 Mojarra 并尝试启动 Tomcat(从 Eclipse 内),则会出现以下异常:
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()
如果我选择 MyFaces I出现以下异常:
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
根据此处的其他答案,我没有将 jar:s 添加到 WEB-INF/lib 文件夹中,并且在项目的构建路径中仅添加 Eclipse 本身包含的库:
- Apache Tomcat v7.0
- EclipseLink 2.3.0
- JSF 2.0 (Apache MyFaces JSF Core-2.0 API 2.0.2)
- MySQL JDBC 驱动程序
该项目本身很小,包含两个 xhtml 文件,但没有 beans。
有什么想法吗?
I'm trying to set up a web project in Eclipse (Indigo SR1) on MacOSX with:
Tomcat 7.0.22
JSF 2.0
It is a Dynamic Web Project where I've added the JSF Project Facet through Project Properties.
When adding the JSF Project Facet I get to choose from using either: Mojarra 2.0.3 or Apache MyFaces 2.0.2
If I choose Mojarra and try to start the Tomcat (from within Eclipse) I get the following exception:
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()
If I choose MyFaces I get the following exception:
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
Based on other answers here I have no jar:s added to the WEB-INF/lib folder and in the project's build path only the Libraries included by Eclipse itself are added:
- Apache Tomcat v7.0
- EclipseLink 2.3.0
- JSF 2.0 (Apache MyFaces JSF Core-2.0 API 2.0.2)
- MySQL JDBC Driver
The project itself is minimal and contains two xhtml-files but yet no beans.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此异常表明您在 web 应用程序的运行时类路径中有一个不同 servletcontainer make/version 的 JSP API/impl JAR 文件,该文件与 JSP API 冲突目标运行时本身。
此异常表明您已Web 应用程序的运行时类路径中其他位置的不同 JSF make/版本的 JSF impl JAR 文件与实际加载的 JSF impl 冲突。
这两个异常都归结为 web 应用程序的运行时类路径是脏的。除了
/WEB-INF/lib
文件夹 - 正如您所说,该文件夹似乎是空的 -Tomcat/lib
、JRE/lib
和JRE/lib/ext
由 web 应用程序的运行时类路径覆盖。您应该确保自己没有在其中添加任何 JAR。删除它们(如果有)。为了安全起见,如有必要,请删除/卸载/重新安装 Tomcat 和/或 JRE。然后你应该取消他们的库,除非你真的明白你在做什么。我认为您的 Web 应用程序运行时类路径中的某处有来自 Glassfish 服务器的
javaee.jar
。这至少可以解释两个例外,因为它同时包括标准 JSP API 和 Mojarra API。This exception suggests that you've a JSP API/impl JAR file of a different servletcontainer make/version in the webapp's runtime classpath which conflicts with the JSP API of the target runtime itself.
This exception suggests that you've a JSF impl JAR file of a different JSF make/version elsewhere in the webapp's runtime classpath which conflicts with the JSF impl actually being loaded.
Both exceptions boil down to that the webapp's runtime classpath is dirty. Apart from
/WEB-INF/lib
folder -which seems to be empty, as you said- theTomcat/lib
,JRE/lib
andJRE/lib/ext
are covered by the webapp's runtime classpath. You should ensure that you have not added any JARs in there yourself. Remove them, if any. Remove/uninstall/reinstall if necessary Tomcat and/or JRE to be on the safe side. You should then untouch their libraries, unless you really understand what you're doing.I think that you've a
javaee.jar
from Glassfish server somewhere in your webapp's runtime classpath. That would at least explain the both exceptions as it includes both the standard JSP API and Mojarra API.