如何吞掉 JSF 1.2/Mojarra 中的异常
ViewExpiredException
正在通过重定向到登录屏幕来处理。问题是异常仍然被记录,并且客户强烈希望 server.log
没有异常。
虽然在这种情况下这可能是一个有问题的要求,但我仍然必须实现它。我们使用 Mojarra 并在 JBoss EAP 5.1 上部署
MyFaces 方法< /a> 没有帮助,因为我显然无法使用 Mojarra 包装 MyFacesServlet
我无法应用 JBoss JSF 指南 包装 Faces servlet,因为我在任何地方都找不到 jsf-integration-deployer-jboss-beans.xml。
我无法获得 Ed Burns 提出的 方法 工作。我猜原因是它是针对 JSF2 的,因为我在 jar 中找不到 javax.faces.context.ExceptionHandlerFactory 。
更糟糕的是,我对 JSF 还很陌生,所以我必须依赖详细的指导,在寻找这些指导时我找到了上述方法,但未能应用它们。
谢谢
The ViewExpiredException
is being handled by a redirect to the login screen. The problem is that the exception is still logged, and the customer would strongly like to have the server.log
exception-free.
While it may be a questionable requirement in this case, I still have to make it happen. We use Mojarra and deploy on JBoss EAP 5.1
The MyFaces approach does not help as I obviously cannot wrap the MyFacesServlet
using Mojarra
I could not apply the advice given in the JBoss JSF guide to wrap the Faces servlet as I cannot find the jsf-integration-deployer-jboss-beans.xml
anywhere.
I cannot get the approach proposed by Ed Burns to work either. I guess the reason is that it is targeted at JSF2 for I cannot find the javax.faces.context.ExceptionHandlerFactory
in my jars.
Making the matter worse, I am quite new to JSF, so I have to rely on detailed guidance, in search of which I have found the above approaches but failed to apply them.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那篇文章确实是针对 JSF 2.x 的。 JSF 1.x 没有任何异常处理工具。
只需捕获并重定向您自己,而不是让容器来做。过滤器是一个明智的选择:
在
web.xml
中将其映射到FacesServlet
的 servlet 名称上以使其运行。That article is indeed targeted on JSF 2.x. JSF 1.x does not have any exception handling facility.
Just catch and redirect yourself instead of letting the container do. A filter is a sensible place for this:
Map this in
web.xml
on the servlet name of theFacesServlet
to get it to run.我在 JSF 2.0 中遇到了同样的问题,实现是由 IBM Websphere 8.5.5.3 提供的。
我尝试使用 ExceptionHandlerWrapper 来检查 ViewExpiredException 和
重定向到会话过期页面(或登录页面),但我无法消除以下错误,遗憾的是此错误在处理程序之前打印:
但我设法通过实现一个 servlet 过滤器来解决它,该过滤器将检查任何潜在的 ViewExpiredException,它将其重定向到会话过期页面(如果有)。
编辑:您需要确保这是过滤器链中的第一个过滤器,如果存在先前的过滤器并且此过滤器创建了一个会话,则上述解决方案将不适用于您。
I faced the same issue in JSF 2.0, the implementation is provided by the IBM Websphere 8.5.5.3 .
I tried to use an ExceptionHandlerWrapper to check for the ViewExpiredException and
redirect to session expired page (or login page), but I couldn't silence the below error, sadly this error is printed before the handler:
But I manged to solve it by implementing a servlet filter which will check for any potential ViewExpiredException, it will redirect it to session expired page if any.
Edit : you need to make sure that this is the first filter in the filters chain, if there's a previous filter and this filter created a session the above solution will not work for you.