1

“错误 500:com.ocpsoft.pretty.PrettyFilter 与 javax.servlet.Filter 不兼容”

  • JSF2.1.2
  • Prettyfaces-jsf2-3.3.2
  • Primefaces 3.2
  • WebSphere 应用服务器 7.0.0.9

尝试在 WebSphere 管理控制台中添加自定义属性以实现过滤器兼容性(在http://ocpsoft.org/prettyfaces/的常见问题解答中最后)。Tomcat 6.0.32 没有任何问题,但是一旦在 WAS 中部署应用程序就会出现问题。

下面是webxml

<context-param>
    <param-name>defaultHtmlEscape</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>com.sun.faces.numberOfViewsInSession</param-name>
    <param-value>3</param-value>
</context-param>

<context-param>
    <param-name>com.sun.faces.numberOfLogicalViews</param-name>
    <param-value>10</param-value>
</context-param>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:WEB-INF/Controller-servlet.xml</param-value>
</context-param>

<context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>

 <context-param>
    <description>JSF Injection provider</description>
    <param-name>com.sun.faces.injectionProvider</param-name>
    <param-value>net.devgrok.jsf.Tomcat6GuiceInjectionProvider</param-value>
</context-param>

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>cupertino</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
    <param-value>abc.xhtml</param-value>
</context-param>

<!--  JSF Required Context Params END-->

<!--  JSF Required Filters & Listeners START-->
<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    <init-param>
        <param-name>thresholdSize</param-name>
        <param-value>1048576000</param-value><!--51200-->
    </init-param>
    <init-param>
        <param-name>uploadDirectory</param-name>
        <param-value>/temp</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<!-- Creates the Spring Container shared by all Servlets and Filters -->

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>

</filter-mapping>

<!--  JSF Required Filters & Listeners END-->

<!--  JSF Required Servlets START -->

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
4

1 回答 1

3
  1. 在 WebSphere 管理控制台中将 war 类加载器顺序更改为“最后一个父级”,并将策略更改为“应用程序的单个类加载器”,以选择应用程序自己的 JSF 版本。

  2. 从 WEB-INF/Lib 文件夹中删除了多余的 jar(servlet-api.jar 和 xml-apis-1.0.b2.jar),因为它与服务器版本冲突。

以上解决了这个问题。但是,当您有可能与服务器版本冲突的特定于应用程序的依赖项时,创建隔离共享库 ( https://stackoverflow.com/a/12081307/1341062 ) 将是更好的选择。

于 2012-08-18T17:04:39.717 回答