Eclipse/Tomcat 6 无法识别 Facelets 选项卡库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2373737/
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-09-19 14:28:47  来源:igfitidea点击:

Facelets tab lib not recognised by Eclipse/Tomcat 6

eclipsejsffaceletsmyfaces

提问by volvox

I included this in my index.jsp JSF file:

我将它包含在我的 index.jsp JSF 文件中:

<%@ taglib prefix="ui" uri="http://java.sun.com/jsf/facelets"%>

and Eclipse underlines the URL, hovering gives this:

和 Eclipse 在 URL 下划线,悬停给出:

Cannot find the tag library descriptor for "http://java.sun.com/jsf/facelets"

Deploying and trying to start Tomcat 6 using the Tomcat plugin causes this:

使用 Tomcat 插件部署并尝试启动 Tomcat 6 会导致:

|STDOUT| 2010-03-03 17:57:29,872 | INFO  | [main]: Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
    |STDOUT| 2010-03-03 17:57:29,904 | INFO  | [main]: ServletContext 'C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myapp\' initialized.
    |STDOUT| 2010-03-03 17:57:29,904 | INFO  | [main]: Checking for plugins:org.apache.myfaces.FACES_INIT_PLUGINS
    03-Mar-2010 17:57:29 org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart
    03-Mar-2010 17:57:29 org.apache.catalina.core.StandardContext start
    SEVERE: Context [/myapp] startup failed due to previous errors

...

...

03-Mar-2010 17:57:30 com.sun.faces.config.ConfigureListener contextDestroyed
SEVERE: Unexpected exception when attempting to tear down the Mojarra runtime
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
    at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:804)

My web.xml contains this

我的 web.xml 包含这个

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

My face-config.xml contains this

我的 face-config.xml 包含这个

    <application>
    <!-- tell JSF to use Facelets -->
    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>

And my application build has the latest JSF 2.0.2 jsf-api.jar and jsf-impl.jar. I've also got MyFaces 1.2.8 and all the latest commons jars. The app was building fine til I upgraded JSF. I would at least expect a run time error but here Eclipse cannot see the taglib. What else could I be missing?

我的应用程序构建有最新的 JSF 2.0.2 jsf-api.jar 和 jsf-impl.jar。我还有 MyFaces 1.2.8 和所有最新的 Commons jar。该应用程序构建良好,直到我升级 JSF。我至少预计会出现运行时错误,但在这里 Eclipse 看不到 taglib。我还能缺少什么?

EDIT

编辑

For full information - I took out Mojarra and left in Myfaces. This meant I needed to remove this from my web.xml:

有关完整信息 - 我取出 Mojarra 并留在 Myfaces 中。这意味着我需要从我的web.xml

<listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener> 

and replace it with the equivalent for myfaces:

并将其替换为 myfaces 的等效项:

<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

Thanks

谢谢

回答by Bozho

Do not mix JSF 2.0 with JSF pre-2.0. It may lead to unexpected results (like the one above).

不要将 JSF 2.0 与 JSF pre-2.0 混合使用。它可能会导致意想不到的结果(如上面的那个)。

Choose a JSF 2.0 implementation (mojarra as it seems) and remove all myfaces and facelets libraries.

选择一个 JSF 2.0 实现(看起来像 mojarra)并删除所有 myfaces 和 facelets 库。

回答by volvox

Well that's annoying. I read in a couple of places that the new Mojarra release embedded facelets. I added jsf-facelets-1.1.14.jar to my build and it deployed ok.

嗯,这很烦人。我在几个地方读到新的 Mojarra 版本嵌入了 facelets。我将 jsf-facelets-1.1.14.jar 添加到我的构建中,并且部署正常。