Jsf 2 重定向到<;错误页面>;已配置(HTTP 500)
我在重定向到web.xml(HTTP 500)中配置的错误页面时遇到问题。 正在引发以下异常Jsf 2 重定向到<;错误页面>;已配置(HTTP 500),jsf-2,omnifaces,Jsf 2,Omnifaces,我在重定向到web.xml(HTTP 500)中配置的错误页面时遇到问题。 正在引发以下异常 java.lang.NullPointerException at java.lang.StringBuilder.<init>(StringBuilder.java:77) at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.getRenderedViewId(FaceletViewDeclarationL
java.lang.NullPointerException at java.lang.StringBuilder.<init>(StringBuilder.java:77)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.getRenderedViewId(FaceletViewDeclarationLanguage.java:1674)
FullAjaxExceptionHandler: Well, another exception occurred during rendering error page 'comum/paginas/erro/erro500.xhtml'. Trying to render a hardcoded error page now.
java.lang.NullPointerException位于java.lang.StringBuilder。(StringBuilder.java:77)
位于org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.getRenderedViewId(FaceletViewDeclarationLanguage.java:1674)
FullAjaxExceptionHandler:在呈现错误页面“coum/paginas/erro/erro500.xhtml”时发生了另一个异常。正在尝试呈现硬编码错误页。
web.xml
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>comum/paginas/erro/sessaoExpirada.xhtml</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>comum/paginas/erro/erro500.xhtml</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>comum/paginas/erro/erro500.xhtml</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>comum/paginas/erro/erro403.xhtml</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>comum/paginas/erro/erro404.xhtml</location>
</error-page>
javax.faces.application.ViewExpiredException
comum/paginas/erro/sessaoExpirada.xhtml
java.lang.Throwable
comum/paginas/erro/erro500.xhtml
500
comum/paginas/erro/erro500.xhtml
403
comum/paginas/erro/erro403.xhtml
404
comum/paginas/erro/erro404.xhtml
FullAjaxExceptionHandlerFactory已在faces-config.xml中配置
<factory>
<exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory>
</factory>
org.omnifaces.exceptionhandler.fullajaxexceptionhandler工厂
我的facelets组件打包在一个jar文件(/META-INF/resources/comum/paginas/erro)中。
资源分解器
<context-param>
<param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
<param-value>company.FaceletsResourceResolver</param-value>
</context-param>
public class FaceletsResourceResolver extends ResourceResolver {
private ResourceResolver parent;
private String basePath;
public FaceletsResourceResolver(ResourceResolver parent) {
this.parent = parent;
this.basePath = "/META-INF/resources";
}
@Override
public URL resolveUrl(String path) {
URL url = parent.resolveUrl(path); // Resolves from WAR.
if (url == null) {
url = getClass().getResource(basePath + path); // Resolves from JAR.
}
return url;
}
}
javax.faces.FACELETS\u资源\u解析器
company.FaceletsResourceResolver
公共类FaceletsResourceResolver扩展了ResourceResolver{
私有资源解析器父级;
私有字符串基路径;
公共FaceletsResourceResolver(资源解析程序父级){
this.parent=parent;
this.basePath=“/META-INF/resources”;
}
@凌驾
公共URL解析URL(字符串路径){
URL URL=parent.resolveUrl(路径);//从WAR解析。
如果(url==null){
url=getClass().getResource(basePath+path);//从JAR解析。
}
返回url;
}
}
当facelets组件没有打包在jar中时,重定向工作正常。
其他错误页面(403404,sessionExpired)工作正常。
该错误仅在HTTP 500错误时发生
环境:
- Websphere 8.5.5.2
- JSF2.0(myfaces)
- Primefaces 5.0
- Omnifaces 1.7
需要以/
开头
例如
<location>comum/paginas/erro/erro500.xhtml</location>
com/paginas/erro/erro500.xhtml
一定是
<location>/comum/paginas/erro/erro500.xhtml</location>
/comum/paginas/erro/erro500.xhtml
“嗯,在呈现错误页面'coum/paginas/erro/erro500.xhtml'时发生了另一个异常情况。”看起来很清楚;您的erro500.xhtml文件显然无法呈现,因此可能包含错误。看起来也是一个打字错误,我希望文件名为error500.xhtml。“erro”是葡萄牙语的“error”。@Gimby这不是一个打字错误,“erro”是巴西葡萄牙语。