I want to implement a custom PhaseListener in my faces-config.xml like it is suggested at stack overflow. So this is my faces-config.xml:
<lifecycle>
<phase-listener>org.apache.myfaces.extensions.validator.core.startup.ExtValStartupListener</phase-listener>
<phase-listener>org.apache.myfaces.extensions.validator.beanval.startup.JSF2AwareBeanValidationStartupListener</phase-listener>
<phase-listener>org.apache.myfaces.extensions.validator.beanval.startup.BeanValidationStartupListener</phase-listener>
<phase-listener>de.azt.MyPhaseListener</phase-listener>
</lifecycle>
And this is MyPhaseListener-Dummy:
public class MyPhaseListener implements PhaseListener {
@Override
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
@Override
public void beforePhase(PhaseEvent event) {
// Do your job here which should run right before the RENDER_RESPONSE.
}
@Override
public void afterPhase(PhaseEvent event) {
// Do your job here which should run right after the RENDER_RESPONSE.
}
}
But this approach leads the application server to crash:
HTTP Status 500 - serialFactory
type Exception report
message serialFactory
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: serialFactory
javax.faces.webapp.FacesServlet.service(FacesServlet.java:229)
org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
ch.ivyteam.ivy.dialog.execution.jsf.controller.rest.IvyRestServiceFilter.doFilter(IvyRestServiceFilter.java:54)
ch.ivyteam.ivy.dialog.execution.jsf.controller.IvyFacesInstanceFilter.filterAsSystem(IvyFacesInstanceFilter.java:104)
ch.ivyteam.ivy.dialog.execution.jsf.controller.IvyFacesInstanceFilter.access$0(IvyFacesInstanceFilter.java:79)
ch.ivyteam.ivy.dialog.execution.jsf.controller.IvyFacesInstanceFilter$1.call(IvyFacesInstanceFilter.java:55)
ch.ivyteam.ivy.dialog.execution.jsf.controller.IvyFacesInstanceFilter$1.call(IvyFacesInstanceFilter.java:1)
ch.ivyteam.ivy.security.internal.SecurityManager.executeAsSystem(SecurityManager.java:1425)
So how is it possible to implement a custom PhaseListener?
asked
22.11.2013 at 16:31
Nikel Weis
(suspended)
accept rate:
57%
Hi Nikel,
I suppose this error appears at the start of your app? Have you exported your Phaselistener-Class in to a jar File? The application can only interpret compiled class files if you declare them in the xml file. So you have to export your package and insert the jar file into the lib-folder.
@Raphael: Thanks for the push into the right direction! The application does not crash at startup anymore.