当同时使用PrimeFaces和faces-config时,我得到一个NullPointerException。在添加faces-config.xml之前,一切都很正常。在添加faces-config.xml以更改导航后,调用每个页面时都会出现以下错误:
java.lang.NullPointerException
org.primefaces.context.PrimeFacesContext.release(PrimeFacesContext.java:26)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:612)
org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98)
de.mypackage.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:19)CharacterEncodingFilter只是确保了UTF-8的使用:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);
}所以这不可能是一个误差源。faces-config.xml包含以下文本:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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-facesconfig_1_2.xsd"
version="1.2">
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>index</from-outcome>
<to-view-id>/index.jsf</to-view-id>
</navigation-case>
</navigation-rule>
这应该引导每个链接索引到一个index.jsf,而不是关于当前网站在哪个文件夹中。但是如果faces-config.xml是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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-facesconfig_1_2.xsd"
version="1.2">
出现相同的错误。
一切都在Tomcat7上运行。
对这个错误的搜索没有包含太多的结果,在http://forum.primefaces.org/viewtopic.php?f=3&t=30109&start=10中,似乎有人在PrimeFaces 4.0的旧版本中遇到了同样的问题,但由于我是从maven获得的,这不可能是我的错误。
有谁能给出一个解决这个问题的建议吗?
发布于 2014-01-11 05:21:32
该问题可能与使用JBoss Seam邮件和PrimeFaces 4.0有关:
http://forum.primefaces.org/viewtopic.php?f=3&t=34653
在我的例子中,我使用的是PrimeFaces v3.4.2,一切都工作得很好。
在升级到官方maven的PrimeFaces v4.0之后,同样的NPE出现了。
My faces-config.xml:<faces-config version="2.1">
发布于 2013-10-24 14:10:38
事实上,Primefaces 4不适用于JSF 1.2,但它确实适用于JSF 2.2之前的版本。
来自Primefaces文档:
PrimeFaces 4.0使用功能检测同时支持JSF2.0、2.1和2.2运行时,并且不依赖于特定版本。因此,某些功能仅在运行时才可用。
https://stackoverflow.com/questions/19514160
复制相似问题