我有一个使用Eclipse Mars,JSF 1.2,RichFaces 3.3.3,Hibernate 3.2.0,Java 1.7的Maven应用程序,当尝试在glassfish 4.1.2中发布时出现以下错误:
Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: Can not create Lifecycle for ID: com.sun.faces.lifecycle.PARTIAL.
...
Exception during lifecycle processing
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: Can not create Lifecycle for ID: com.sun.faces.lifecycle.PARTIAL
在执行maven:clean并尝试重新发布该应用程序后,出现以下错误:
WebModule[/CA-Client]Servlet Faces Servlet threw unload() exception
javax.servlet.ServletException: Servlet.destroy() for servlet Faces Servlet threw exception
....
Caused by: java.lang.NullPointerException
at javax.faces.webapp.FacesServlet.uninitHttpMethodValidityVerification(FacesServlet.java:511)
...
Critical error during deployment:
com.sun.faces.config.ConfigurationException:
Source Document: jndi:/server/CA-Client/WEB-INF/faces-config.xml
Cause: Unable to create a new instance of 'caclient.listener.CtrPhaseListener': javax.faces.FacesException: caclient.listener.CtrPhaseListener
我的faces.config是
<lifecycle>
<phase-listener>caclient.listener.CtrPhaseListener</phase-listener>
</lifecycle>
我的侦听器类是:
src/main/java/caclient.listener.CtrPhaseListener.java
我的面孔配置是:
src/main/java/webapp/WEB-INF/faces.config.xml
我的CtrPhaseListener.class
public class CtrPhaseListener implements PhaseListener {
private static final String PASSED_PAGES = "/Login.jsp, /AlterarSenha.jsp";
private Date ultimoAcesso = null;
public void afterPhase(PhaseEvent event) {}
public void beforePhase(PhaseEvent event) {
FacesContext ctx = event.getFacesContext();
String paginaDestino = ctx.getViewRoot().getViewId();
ctx = event.getFacesContext();
HttpSession session = (HttpSession) ctx.getExternalContext().getSession(false);
ultimoAcesso = (ultimoAcesso == null) ? new Date() : ultimoAcesso;
SimpleDateFormat sdf = new SimpleDateFormat("HHmm");
int mins = Integer.parseInt(sdf.format(new Date())) - Integer.parseInt(sdf.format(ultimoAcesso));
if (/*mins > 10 || */session == null || session.getAttribute("sessionUser") == null) {
if (!PASSED_PAGES.contains(paginaDestino) && paginaDestino.contains(".jsp")) {
try {
//se não existir direciona para a página de LOGIN
ultimoAcesso = null;
session.setAttribute("sessionUser", null);
ctx.getExternalContext().redirect("faces/Login.jsp");
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
ultimoAcesso = new Date();
}
public PhaseId getPhaseId() {
return PhaseId.APPLY_REQUEST_VALUES;
}
}
是由于Maven创建的“ src / main / java”文件夹引起的问题吗?