在 Eclipse 动态 Web 项目中使用 JSF 时 Tomcat 中抛出异常

发布于 2024-12-16 02:30:45 字数 928 浏览 0 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葵雨 2024-12-23 02:30:45

如果我选择 Mojarra 并尝试启动 Tomcat(从 Eclipse 内),我会收到以下异常:

java.lang.LinkageError:加载器约束冲突:解析接口方法“javax.servlet.jsp.JspApplicationContext.getExpressionFactory()”时

此异常表明您在 web 应用程序的运行时类路径中有一个不同 servletcontainer make/version 的 JSP API/impl JAR 文件,该文件与 JSP API 冲突目标运行时本身。


如果我选择 MyFaces,则会出现以下异常:

java.lang.IllegalStateException:应用程序在启动时未正确初始化,找不到工厂:javax.faces.application.ApplicationFactory

此异常表明您已Web 应用程序的运行时类路径中其他位置的不同 JSF make/版本的 JSF impl JAR 文件与实际加载的 JSF impl 冲突。


这两个异常都归结为 web 应用程序的运行时类路径是脏的。除了 /WEB-INF/lib 文件夹 - 正如您所说,该文件夹似乎是空的 - Tomcat/libJRE/libJRE/lib/ext 由 web 应用程序的运行时类路径覆盖。您应该确保自己没有在其中添加任何 JAR。删除它们(如果有)。为了安全起见,如有必要,请删除/卸载/重新安装 Tomcat 和/或 JRE。然后你应该取消他们的库,除非你真的明白你在做什么。

我认为您的 Web 应用程序运行时类路径中的某处有来自 Glassfish 服务器的 javaee.jar。这至少可以解释两个例外,因为它同时包括标准 JSP API 和 Mojarra API。

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()

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.


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

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- the Tomcat/lib, JRE/lib and JRE/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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文