【问题标题】:Unable to load servlet listener class: com.sun.faces.config.ConfigureListener无法加载 servlet 侦听器类:com.sun.faces.config.ConfigureListener
【发布时间】:2015-06-17 12:38:13
【问题描述】:

我正在使用 apache-tomee-jaxrs-1.7.1,我正在尝试使用 maven 3 进行部署,但出现此错误:

无法加载 servlet 侦听器类:com.sun.faces.config.ConfigureListener:

这些是我在 pom.xml 中的依赖项:

  ...
  <dependencies>
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp.jstl</groupId>
      <artifactId>jstl-api</artifactId>
      <version>1.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.openjpa</groupId>
      <artifactId>openjpa</artifactId>
      <version>2.3.0</version>
    </dependency>
  </dependencies>
  ...

有什么想法吗?提前致谢。

【问题讨论】:

    标签: maven jsf apache-tomee


    【解决方案1】:

    只需去掉 webapp 的 web.xml 中提到的异常 &lt;listener&gt; 条目。

    TomEE 附带 MyFaces,而不是 Mojarra。 web.xml 中的特定于 Mojarra 的 &lt;listener&gt; 条目通常被一些 IDE 自动包含,它们试图比它们更聪明和/或被抛在质量差的开源项目中。小心他们。在体面的容器上不需要显式注册。另见 a.o. Configuration of com.sun.faces.config.ConfigureListener.

    【讨论】:

    • 你完全正确。我在 web.xml 中添加了&lt;listener-class&gt;org.apache.myfaces.webapp.StartupServletContextListener&lt;/listener-class&gt;,现在可以使用了!很抱歉这个愚蠢的问题,非常感谢。
    • 那个也不应该是必要的。这些侦听器应该无需任何额外配置即可自动注册。这只会在有问题的容器中失败(如该链接中所述),但据我所知,常规的 TomEE 容器没有这个问题。
    猜你喜欢
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-29
    • 1970-01-01
    • 2012-08-29
    • 1970-01-01
    • 2011-08-16
    相关资源
    最近更新 更多