将 RichFaces 添加到现有 JBoss Seam 应用程序

发布于 2024-12-13 02:00:46 字数 20188 浏览 3 评论 0原文

给定一个使用 Jboss seam 构建的 Web 应用程序,其中包含以下详细信息:

 dynamic web module: 2.3
 Java : 1.5
 Javascript: 1.0
 Tomcat: 5.0
    activation.jar
    commons-beanutils-1.7.0.jar
    commons-codec-1.3.jar
    commons-digester-1.6.jar
    commons-el-1.0.jar
    commons-fileupload-1.0.jar
    commons-lang-2.1.jar
    commons-logging-1.0.4.jar
    jstl-1.1.0.jar
    jxl.jar
    log4j-1.2.8.jar
    myfaces-api-1.1.5.jar
    myfaces-impl-1.1.5.jar
    standard.jar
    tomahawk-1.1.3.jar

查看了 RichFaces 及其提供的功能后,我喜欢将其添加到应用程序中,并尝试(但失败了)通过创建一个新应用程序来实现这一点,其中包含:

 dynamic web module: 2.5
 Java: 1.5
 Javascript: 1.0
 Tomcat : 6.0

以及我可以做的在线集合以满足 Richfaces 库的要求,同时也能够部署现有应用程序 我将以下库添加到新项目中:

    activation.jar
    common-annotations.jar
    commons-beanutils-1.7.0.jar
    commons-codec-1.3.jar
    commons-collections-3.2.jar
    commons-digester-1.8.jar
    commons-discovery-0.4.jar
    commons-el-1.0.jar
    commons-fileupload-1.0.jar
    commons-lang-2.1.jar
    commons-logging-1.1.1.jar
    jsf-api.jar
    jsf-impl.jar
    jsf-tlds.jar
    jstl.jar
    jxl.jar
    log4j-1.2.8.jar
    myfaces-api-1.2.9.jar
    myfaces-impl-1.2.9.jar
    richfaces-api-3.3.3.Final.jar
    richfaces-impl-3.3.3.Final.jar
    richfaces-ui-3.3.3.Final.jar
    standard.jar
    tomahawk-1.1.3.jar

我将所需的 richfaces 标签添加到 web.xml 中。我可以部署并运行该应用程序,并且可以看到 richfaces 皮肤应用于页面上的所有控件(bluesky),但显然设置有问题。链接重定向似乎不起作用(例如从登录屏幕到主页...等)以及调用 backbean 时出现空异常问题...等。从我读到的内容来看,库冲突可能是原因,但我保留了上述内容,因为删除 myfaces 或 jsf jar 将不允许部署应用程序。

我的问题:混合 RichFaces 和 MyFaces 是一个坏主意吗(或者实际上根本不应该这样做?)。我添加上述库的主要原因是能够运行我们拥有的应用程序,同时还可以向其中添加 RichFaces,我希望有人能告诉我上面不必要的(冲突的)库以及我应该遵循的添加 Richfaces 的正确路径此接缝应用。

更新:

正如所建议的,JSF 和 MyFaces 库是冲突的,因此我尝试删除一个并保留另一个。下面是我删除 JSF 库 jsf-impl.jar 时收到的错误 jsf-tlds.jar jsf-api.jar 并保留 myfaces 库:

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/sun/faces/taglib/jsf_core/ViewTag

Caused by:
java.lang.ClassNotFoundException - com.sun.faces.taglib.jsf_core.ViewTag


- Stack Trace
javax.faces.FacesException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/sun/faces/taglib/jsf_core/ViewTag
    at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:347)
    at org.apache.myfaces.application.jsp.JspViewHandlerImpl.buildView(JspViewHandlerImpl.java:486)

从我所见,我可以看出错误是由如下标签引起的:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

删除 MyFaces 库 myfaces-api-1.2.9.jar myfaces-impl-1.2.9.jar 并保留 JSF 库会导致 HTTP Status 404 并出现以下错误:

02/11/2011 11:47:53 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8165
02/11/2011 11:47:53 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 432 ms
02/11/2011 11:47:53 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
02/11/2011 11:47:53 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.33
02/11/2011 11:47:54 AM org.apache.catalina.core.StandardContext addApplicationLi
stener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configure
d for this context. The duplicate definition has been ignored.
02/11/2011 11:47:54 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
02/11/2011 11:47:54 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/TestProj] startup failed due to previous errors
02/11/2011 11:47:54 AM org.apache.catalina.loader.WebappClassLoader clearReferen
cesJdbc
SEVERE: The web application [/TestProj] registered the JDBC driver [org.postgres
ql.Driver] but failed to unregister it when the web application was stopped. To
prevent a memory leak, the JDBC Driver has been forcibly unregistered.
02/11/2011 11:47:54 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
02/11/2011 11:47:54 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
02/11/2011 11:47:54 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
02/11/2011 11:47:54 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8165
02/11/2011 11:47:54 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
02/11/2011 11:47:54 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/15  config=null
02/11/2011 11:47:54 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 767 ms

其中有趣的一点是SEVERE:Error ListenerStart

下面是我使用的 web.xml:

web.xml

 <?xml version="1.0"?>
 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>blueSky</param-value>
</context-param>
<context-param>
    <param-name>org.richfaces.CONTROL_SKINNING</param-name>
    <param-value>enable</param-value>
</context-param>
<filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
    <filter-name>richfaces</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<filter>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-  
  class>
    <init-param>
        <param-name>maxFileSize</param-name>
        <param-value>20m</param-value>
    </init-param>
</filter>
<!-- extension mapping for adding <script/>, <link/>, and other resource 
    tags to JSF-pages -->
<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
  javax.faces.webapp.FacesServlet 
        entry -->
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>

</context-param>

<context-param>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value>

</context-param>

<context-param>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>

</context-param>

<context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
</context-param>

<context-param>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>

</context-param>
<listener>
    <listener-class>
        org.apache.myfaces.webapp.StartupServletContextListener</listener-
  class>
</listener>
<listener>
    <listener-class>testProj.SessionExpireHandler</listener-class>
</listener>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
</servlet-mapping>
<filter>
    <filter-name>Faces Servlet</filter-name>
    <filter-class>testProj.SessionHandler</filter-class>
</filter>
<filter-mapping>
    <filter-name>Faces Servlet</filter-name>
    <url-pattern>*.faces</url-pattern>
</filter-mapping>
<!-- Welcome files -->
<welcome-file-list>
    <welcome-file>jsp/index.jsp</welcome-file>
</welcome-file-list>
<session-config>
    <session-timeout>60</session-timeout>

</session-config>

 </web-app>

更新 2:

按照建议,lib 文件夹中剩余的 Mojarra 的最后一点是 jsf-tlds.jar 这是现在已删除。我正在运行的 Tomcat 版本是 tomcat-6.0.33。我还将 myfaces 更新至 2.1Tomahawk 至 1.1.11 以及所有相关库。下面是更新后的完整 lib jar 列表:

activation.jar
batik-awt-util-1.6-1.jar
batik-ext-1.6-1.jar
batik-gui-util-1.6-1.jar
batik-util-1.6-1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.2.1.jar
commons-digester-1.6.jar
commons-el-1.0.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-lang-2.4.jar
commons-logging-1.1.1.jar
commons-validator-1.3.1.jar
iText-2.1.2u.jar
jstl.jar
jxl.jar
log4j-1.2.8.jar
mail.jar
myfaces-api-2.1.3.jar
myfaces-impl-2.1.3.jar
Opta2000.jar
oro-2.0.8.jar
postgresql-8.4-701.jdbc3.jar
richfaces-api-3.3.3.Final.jar
richfaces-impl-3.3.3.Final.jar
richfaces-ui-3.3.3.Final.jar
standard.jar
tomahawk20-1.1.11.jar
xml-apis-1.0.b2.jar
xmlParserAPIs-2.0.2.jar

我还

<!-- Listener, that does all the startup work (configuration, init). -->
<listener>
    <listener-class>
        org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

从网络中删除了它。 xml(未进行其他更改)。我可以部署应用程序,但导航到登录页面会显示 HTTP Status 500 - 并引发异常,如下所示:

[2011-11-02 15:16:50,775] ERROR: org.ajax4jsf.webapp.BaseXMLFilter - Exception in the filter chain
javax.servlet.ServletException: /jsp/login.facesNo saved view state could be found for the view identifier: /jsp/login.faces
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:205)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dbschenker.util.SessionHandler.doFilter(SessionHandler.java:34)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.application.ViewExpiredException: /jsp/login.facesNo saved view state could be found for the view identifier: /jsp/login.faces
    at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:128)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
    ... 24 more

UPDATE 3:

downgraded myfaces to MyFaces Core 2.0.9 ,异常与下面相同:

[2011-11-02 16:10:59,260] ERROR: org.ajax4jsf.webapp.BaseXMLFilter - Exception in the filter chain
javax.servlet.ServletException: /jsp/login.facesNo saved view state could be found for the view identifier: /jsp/login.faces
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:205)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dbschenker.util.SessionHandler.doFilter(SessionHandler.java:34)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.application.ViewExpiredException: /jsp/login.facesNo saved view state could be found for the view identifier: /jsp/login.faces
    at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:128)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
    ... 24 more

请注意,这是否值得一提,但 tomahawk 和 myfaces 中都存在以下库:

##tomahawk#
commons-logging-1.1.1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.2.1.jar
commons-digester-1.6.jar

#myfaces 2.0.9
commons-beanutils-1.8.3.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-logging-1.1.1.jar

我正在使用 tomahawk 附带的库。

在线研究上述异常与会话有关,其中页面提交包含不再存在的服务器端视图状态的 ID。这是由于我的 web.xml 中的配置错误吗?请注意,我正在执行如下会话处理:

web.xml:

  <listener>
    <listener-class>testProj.SessionExpireHandler</listener-class>
</listener>
<filter>
    <filter-name>Faces Servlet</filter-name>
    <filter-class>com.dbschenker.util.SessionHandler</filter-class>
</filter>
<filter-mapping>
    <filter-name>Faces Servlet</filter-name>
    <url-pattern>*.faces</url-pattern>
</filter-mapping>

SessionHandler.java:

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SessionHandler implements Filter {
    private String  timeoutPage;

    public void init(FilterConfig filterConfig) throws ServletException {
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) {
            HttpServletRequest httpServletRequest = (HttpServletRequest) request;
            HttpServletResponse httpServletResponse = (HttpServletResponse) response;
            if (isSessionControlRequiredForThisResource(httpServletRequest)) {
                if (isSessionInvalid(httpServletRequest)) {
                    try {
                        httpServletRequest.getSession().setAttribute("sexpiremessage", ApplicationConstant.SESSION_EXP);
                        RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/jsp/login.faces");
                        String timeoutUrl = httpServletRequest.getContextPath() + "/" + getTimeoutPage();
                        httpServletResponse.sendRedirect(timeoutUrl);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    return;
                }
            }
        }
        try {
            filterChain.doFilter(request, response);
        } catch (Exception e) {
            // e.printStackTrace();
        }
    }

    private boolean isSessionControlRequiredForThisResource(HttpServletRequest httpServletRequest) {
        String requestPath = httpServletRequest.getRequestURI();
        boolean controlRequired = !(requestPath.endsWith("/login.faces"));
        return controlRequired;
    }

    private boolean isSessionInvalid(HttpServletRequest httpServletRequest) {
        boolean sessionInValid = false;
        try {
            sessionInValid = (httpServletRequest.getRequestedSessionId() != null) && !httpServletRequest.isRequestedSessionIdValid();
            if (httpServletRequest.getSession().getAttribute(ApplicationConstant.SESSION_INFO_KEY) == null)
                sessionInValid = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sessionInValid;
    }

    public void destroy() {
    }

    public String getTimeoutPage() {
        return "jsp/login.faces";
    }

    public void setTimeoutPage(String timeoutPage) {
        this.timeoutPage = timeoutPage;
    }
}

认为我不清楚为什么抛出异常!

Given a web application built using Jboss seam with following details:

 dynamic web module: 2.3
 Java : 1.5
 Javascript: 1.0
 Tomcat: 5.0
    activation.jar
    commons-beanutils-1.7.0.jar
    commons-codec-1.3.jar
    commons-digester-1.6.jar
    commons-el-1.0.jar
    commons-fileupload-1.0.jar
    commons-lang-2.1.jar
    commons-logging-1.0.4.jar
    jstl-1.1.0.jar
    jxl.jar
    log4j-1.2.8.jar
    myfaces-api-1.1.5.jar
    myfaces-impl-1.1.5.jar
    standard.jar
    tomahawk-1.1.3.jar

Having looked at RichFaces and what it offers i like to add it to the application and tried (and failed) doing so by creating a new application where it has:

 dynamic web module: 2.5
 Java: 1.5
 Javascript: 1.0
 Tomcat : 6.0

and from what i could muster online to satisfy the Richfaces libraries but also be able to deploy the existing application i added the following libraries to the new project:

    activation.jar
    common-annotations.jar
    commons-beanutils-1.7.0.jar
    commons-codec-1.3.jar
    commons-collections-3.2.jar
    commons-digester-1.8.jar
    commons-discovery-0.4.jar
    commons-el-1.0.jar
    commons-fileupload-1.0.jar
    commons-lang-2.1.jar
    commons-logging-1.1.1.jar
    jsf-api.jar
    jsf-impl.jar
    jsf-tlds.jar
    jstl.jar
    jxl.jar
    log4j-1.2.8.jar
    myfaces-api-1.2.9.jar
    myfaces-impl-1.2.9.jar
    richfaces-api-3.3.3.Final.jar
    richfaces-impl-3.3.3.Final.jar
    richfaces-ui-3.3.3.Final.jar
    standard.jar
    tomahawk-1.1.3.jar

I added needed richfaces tags to web.xml. I can deploy and run the application and can see richfaces skin applied to all controls on page (bluesky), but clearly something is wrong with the setup. link redirection doesn't seem to work (e.g. from login screen to home page...etc) and null exception issues when calling backbean...etc. From what I've read libraries conflicting could be the cause but i've kept the above as removing myfaces or jsf jars won't allow the app to deploy.

My question: Is mixing RichFaces and MyFaces a bad idea (or indeed one shouldn't do it at all?) . MY main reason for adding the above libraries is to be able to run the application we have but also add RichFaces to it, I would appreciate someone to tell me the unnecessary (Conflicting) libraries above and the correct path i should be following to add Richfaces this seam application.

UPDATE:

As suggested, JSF and MyFaces libraries are conflicting and hence i tried to remove one and keep the other. below is the error i get when i removed the JSF libraries jsf-impl.jar
jsf-tlds.jar
jsf-api.jar
and kept the myfaces libraries:

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/sun/faces/taglib/jsf_core/ViewTag

Caused by:
java.lang.ClassNotFoundException - com.sun.faces.taglib.jsf_core.ViewTag


- Stack Trace
javax.faces.FacesException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/sun/faces/taglib/jsf_core/ViewTag
    at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:347)
    at org.apache.myfaces.application.jsp.JspViewHandlerImpl.buildView(JspViewHandlerImpl.java:486)

from what i see i can tell that the error steams from tags such as below:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

Deleting the MyFaces libraries myfaces-api-1.2.9.jar
myfaces-impl-1.2.9.jar
and keeping the JSF librararies result in HTTP Status 404 with following errors :

02/11/2011 11:47:53 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8165
02/11/2011 11:47:53 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 432 ms
02/11/2011 11:47:53 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
02/11/2011 11:47:53 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.33
02/11/2011 11:47:54 AM org.apache.catalina.core.StandardContext addApplicationLi
stener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configure
d for this context. The duplicate definition has been ignored.
02/11/2011 11:47:54 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
02/11/2011 11:47:54 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/TestProj] startup failed due to previous errors
02/11/2011 11:47:54 AM org.apache.catalina.loader.WebappClassLoader clearReferen
cesJdbc
SEVERE: The web application [/TestProj] registered the JDBC driver [org.postgres
ql.Driver] but failed to unregister it when the web application was stopped. To
prevent a memory leak, the JDBC Driver has been forcibly unregistered.
02/11/2011 11:47:54 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
02/11/2011 11:47:54 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
02/11/2011 11:47:54 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
02/11/2011 11:47:54 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8165
02/11/2011 11:47:54 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
02/11/2011 11:47:54 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/15  config=null
02/11/2011 11:47:54 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 767 ms

with the juicy bit being the SEVERE: Error listenerStart.

below is the web.xml i use:

web.xml:

 <?xml version="1.0"?>
 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>blueSky</param-value>
</context-param>
<context-param>
    <param-name>org.richfaces.CONTROL_SKINNING</param-name>
    <param-value>enable</param-value>
</context-param>
<filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
    <filter-name>richfaces</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<filter>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-  
  class>
    <init-param>
        <param-name>maxFileSize</param-name>
        <param-value>20m</param-value>
    </init-param>
</filter>
<!-- extension mapping for adding <script/>, <link/>, and other resource 
    tags to JSF-pages -->
<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
  javax.faces.webapp.FacesServlet 
        entry -->
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>

</context-param>

<context-param>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value>

</context-param>

<context-param>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>

</context-param>

<context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
</context-param>

<context-param>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>

</context-param>
<listener>
    <listener-class>
        org.apache.myfaces.webapp.StartupServletContextListener</listener-
  class>
</listener>
<listener>
    <listener-class>testProj.SessionExpireHandler</listener-class>
</listener>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
</servlet-mapping>
<filter>
    <filter-name>Faces Servlet</filter-name>
    <filter-class>testProj.SessionHandler</filter-class>
</filter>
<filter-mapping>
    <filter-name>Faces Servlet</filter-name>
    <url-pattern>*.faces</url-pattern>
</filter-mapping>
<!-- Welcome files -->
<welcome-file-list>
    <welcome-file>jsp/index.jsp</welcome-file>
</welcome-file-list>
<session-config>
    <session-timeout>60</session-timeout>

</session-config>

 </web-app>

UPDATE 2:

As suggested the last bit of Mojarra remaining in the lib folder was jsf-tlds.jar which is now removed. Tomcat version i'm running is tomcat-6.0.33. I also updated the myfaces to 2.1 and Tomahawk to 1.1.11 and all related libraries.Below is the updated and full lib jars list:

activation.jar
batik-awt-util-1.6-1.jar
batik-ext-1.6-1.jar
batik-gui-util-1.6-1.jar
batik-util-1.6-1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.2.1.jar
commons-digester-1.6.jar
commons-el-1.0.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-lang-2.4.jar
commons-logging-1.1.1.jar
commons-validator-1.3.1.jar
iText-2.1.2u.jar
jstl.jar
jxl.jar
log4j-1.2.8.jar
mail.jar
myfaces-api-2.1.3.jar
myfaces-impl-2.1.3.jar
Opta2000.jar
oro-2.0.8.jar
postgresql-8.4-701.jdbc3.jar
richfaces-api-3.3.3.Final.jar
richfaces-impl-3.3.3.Final.jar
richfaces-ui-3.3.3.Final.jar
standard.jar
tomahawk20-1.1.11.jar
xml-apis-1.0.b2.jar
xmlParserAPIs-2.0.2.jar

I've also removed

<!-- Listener, that does all the startup work (configuration, init). -->
<listener>
    <listener-class>
        org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

from web.xml (no other changes made). I can deploy the application but navigating to login page gives HTTP Status 500 - and throws an exception as below:

[2011-11-02 15:16:50,775] ERROR: org.ajax4jsf.webapp.BaseXMLFilter - Exception in the filter chain
javax.servlet.ServletException: /jsp/login.facesNo saved view state could be found for the view identifier: /jsp/login.faces
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:205)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dbschenker.util.SessionHandler.doFilter(SessionHandler.java:34)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.application.ViewExpiredException: /jsp/login.facesNo saved view state could be found for the view identifier: /jsp/login.faces
    at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:128)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
    ... 24 more

UPDATE 3:

downgraded myfaces to MyFaces Core 2.0.9 , the exception remains the same as below:

[2011-11-02 16:10:59,260] ERROR: org.ajax4jsf.webapp.BaseXMLFilter - Exception in the filter chain
javax.servlet.ServletException: /jsp/login.facesNo saved view state could be found for the view identifier: /jsp/login.faces
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:205)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.dbschenker.util.SessionHandler.doFilter(SessionHandler.java:34)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.application.ViewExpiredException: /jsp/login.facesNo saved view state could be found for the view identifier: /jsp/login.faces
    at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:128)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
    ... 24 more

note sure if this is worth mentioning but following libraries exist in Both tomahawk and myfaces:

##tomahawk#
commons-logging-1.1.1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.2.1.jar
commons-digester-1.6.jar

#myfaces 2.0.9
commons-beanutils-1.8.3.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-logging-1.1.1.jar

I'm using the ones that came with tomahawk.

Researching online the above exception has to do with session where page submit is including the id of a server-side view state that no longer exists. is this down to misconfiguration in my web.xml ? note that i'm doing the session handling as below:

web.xml:

  <listener>
    <listener-class>testProj.SessionExpireHandler</listener-class>
</listener>
<filter>
    <filter-name>Faces Servlet</filter-name>
    <filter-class>com.dbschenker.util.SessionHandler</filter-class>
</filter>
<filter-mapping>
    <filter-name>Faces Servlet</filter-name>
    <url-pattern>*.faces</url-pattern>
</filter-mapping>

and in SessionHandler.java:

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SessionHandler implements Filter {
    private String  timeoutPage;

    public void init(FilterConfig filterConfig) throws ServletException {
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) {
            HttpServletRequest httpServletRequest = (HttpServletRequest) request;
            HttpServletResponse httpServletResponse = (HttpServletResponse) response;
            if (isSessionControlRequiredForThisResource(httpServletRequest)) {
                if (isSessionInvalid(httpServletRequest)) {
                    try {
                        httpServletRequest.getSession().setAttribute("sexpiremessage", ApplicationConstant.SESSION_EXP);
                        RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/jsp/login.faces");
                        String timeoutUrl = httpServletRequest.getContextPath() + "/" + getTimeoutPage();
                        httpServletResponse.sendRedirect(timeoutUrl);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    return;
                }
            }
        }
        try {
            filterChain.doFilter(request, response);
        } catch (Exception e) {
            // e.printStackTrace();
        }
    }

    private boolean isSessionControlRequiredForThisResource(HttpServletRequest httpServletRequest) {
        String requestPath = httpServletRequest.getRequestURI();
        boolean controlRequired = !(requestPath.endsWith("/login.faces"));
        return controlRequired;
    }

    private boolean isSessionInvalid(HttpServletRequest httpServletRequest) {
        boolean sessionInValid = false;
        try {
            sessionInValid = (httpServletRequest.getRequestedSessionId() != null) && !httpServletRequest.isRequestedSessionIdValid();
            if (httpServletRequest.getSession().getAttribute(ApplicationConstant.SESSION_INFO_KEY) == null)
                sessionInValid = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sessionInValid;
    }

    public void destroy() {
    }

    public String getTimeoutPage() {
        return "jsp/login.faces";
    }

    public void setTimeoutPage(String timeoutPage) {
        this.timeoutPage = timeoutPage;
    }
}

thought not clear to me why the exception is thrown!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

滥情稳全场 2024-12-20 02:00:46

您正在混合 JSF 实现。这些来自 Mojarra

jsf-api.jar
jsf-impl.jar
jsf-tlds.jar

(我从未见过 jsf-tlds .jar,它们似乎源自其他地方,它的 /META-INF/MANIFEST.MF 文件说什么?)

这些来自 MyFaces

myfaces-api-1.2.9.jar
myfaces-impl-1.2.9.jar

这是不允许的。他们只会互相冲突。您应该选择并使用其中之一。

另请参阅:


更新

根据您的更新,MyFaces 出现以下异常,

java.lang.ClassNotFoundException - com.sun.faces.taglib.jsf_core.ViewTag

表明您仍然在类路径中的某处保留了 Mojarra TLD 文件。要么打包在 JAR 中(通常是 jsf-impl.jar,但是 jsf-tlds.jar 非常可疑,我真的很好奇你从哪里得到它以及它们包含的内容),或作为松散的 .tld 文件。换句话说,由于混合了 Mojarra 和 MyFaces 实现,您的运行时类路径仍然很脏。清理Webapp/WEB-INF/libWebapp/WEB-INF/classesTomcat/libJRE/lib code> 等。

以及 Mojarra 的以下信息,

信息:已为此上下文配置侦听器“com.sun.faces.config.ConfigureListener”。重复的定义已被忽略。

这要么是 Tomcat 中的一个错误(您到底使用的是哪个版本?6.0.18 中修复了类似的错误),要么您在 web.xml 中将其作为 不必要地重复。 xml.它应该已经由任何 JSP 2.0 兼容容器(例如 Tomcat 5.5 及更高版本)上的 TLD 文件自动初始化,无论您使用的是 MyFaces 还是 Mojarra。

Mojarra 出现以下错误,

严重:侦听器启动错误

可能是因为您的web.xml中有一个特定于MyFaces的侦听器而引起的:

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

将其完全删除。对于 JSP 2.0 兼容容器上的 MyFaces/Mojarra 根本不需要它。

回到 jsf-tlds.jar,您使用的 Mojarra 版本到底是什么?您从哪里获得它?您知道应该从官方制造商的网站下载库吗? Mojarra 可以从 http://javaserverfaces.java.net 获取。 Tomcat 6.0 兼容的 1.2_15(或者最好是 2.0.6)在那里可用。它由 2 个 JAR 文件 jsf-api.jarjsf-impl.jar 组成。没有神秘的 jsf-tlds.jar 文件。顺便说一下,JSF 2.0 比 JSF 1.2 提供了很多优势。如果可以的话,我强烈建议您也进行升级步骤。


更新 2:您没有透露任何有关异常的信息,因此我无法具体说明。但这看起来不对:

myfaces-api-2.1.3.jar
myfaces-impl-2.1.3.jar

JSF 2.1 需要 Servlet 3.0 兼容容器,而 Tomcat 6.0 是 Servlet 2.5 容器。您需要 JSF 2.0。选择 MyFaces 2.0.x 或 Mojarra 2.0.x,但不要选择 2.1.x。如果您确实需要 JSF 2.1,请将 Tomcat 升级到 7.0。

You're mixing JSF implementations. Those are from Mojarra:

jsf-api.jar
jsf-impl.jar
jsf-tlds.jar

(I've only never seen jsf-tlds.jar, they seem to originate somewhere else, what does its /META-INF/MANIFEST.MF file say?)

Those are from MyFaces:

myfaces-api-1.2.9.jar
myfaces-impl-1.2.9.jar

This isn't allowed. They will only conflict each other. You should choose and use the one or the other.

See also:


Update:

As per your update, the following exception with MyFaces,

java.lang.ClassNotFoundException - com.sun.faces.taglib.jsf_core.ViewTag

suggests that you've still Mojarra TLD files somewhere in the classpath. Either packaged in a JAR (usually, jsf-impl.jar, but that jsf-tlds.jar is very suspicious, I'd really be curious where you got it from and what they contain), or as loose .tld files. In other words, your runtime classpath is still dirty with a mix of Mojarra and MyFaces implementations. Cleanup Webapp/WEB-INF/lib, Webapp/WEB-INF/classes, Tomcat/lib, JRE/lib, etc.

And the following info with Mojarra,

INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.

This is either a bug in Tomcat (which version exactly are you using? a similar bug was fixed in 6.0.18) or you have unnecessarily repeated it as a <listener> in web.xml. It should already be automatically initialized by the TLD file on any JSP 2.0 compatible container such as Tomcat 5.5 and newer, regardless of whether you're using MyFaces or Mojarra.

The following error with Mojarra,

SEVERE: Error listenerStart

is possibly caused because you've a MyFaces specific listener in your web.xml:

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

Remove it altogether. You don't need it at all for both MyFaces/Mojarra on a JSP 2.0 compatible container.

Coming back to the jsf-tlds.jar, what Mojarra version exactly are you using and where did you get it from? You are aware that you are supposed to download the libs from the official manfacturer's site? Mojarra is available at http://javaserverfaces.java.net. The Tomcat 6.0 compatible 1.2_15 (or, preferably, 2.0.6) are available there. It's composed of 2 JAR files jsf-api.jar and jsf-impl.jar. No mysterious jsf-tlds.jar file. JSF 2.0 offers by the way enormously a lot of advantages over JSF 1.2. If you can, I strongly recommend to make that upgrade step as well.


Update 2: You didn't tell anything about the exception, so I can't be specific. But this doesn't look right:

myfaces-api-2.1.3.jar
myfaces-impl-2.1.3.jar

JSF 2.1 requires a Servlet 3.0 compatible container, while Tomcat 6.0 is a Servlet 2.5 container. You need JSF 2.0 instead. Pick MyFaces 2.0.x or Mojarra 2.0.x, but not 2.1.x. If you really need JSF 2.1, upgrade Tomcat to 7.0.

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