I don't know if you need the release() method. I think this method is the reason for your exception. A quote from the javadoc.
Up vote 0 down vote favorite share g+ share fb share tw.
I have a primefaces dock nav bar with a menuitem element, that should trigger the logout mechanism of my web app, but it doesn't work, I don't know why. Can someone help me find the reason why the logout funccion is not called when I click on the menu item? This is the element at the JSF page template: This is the backing bean where the logOut() Method is located: @ManagedBean @RequestScoped public class SecurityController { ... public String logOut() { authentificationEJB.
ReleaseUserState(); return "main. Xhtml"; } ... And this is the EJB that accesses the session and releases it from the logged user: @Stateful(name = "ejbs/AuthentificationEJB") public class AuthentificationEJB implements IAuthentificationEJB { ... // Logout public void releaseUserState() { // 1-Check if there is something saved in the session(or wherever the // state is saved) if (!FacesContext. GetCurrentInstance().
GetExternalContext() .getSessionMap().isEmpty()) { // 2-If 1 then flush it FacesContext. GetCurrentInstance().release(); } } ... } When I click on the menuItem I get this exception: WARNING: StandardWrapperValveFaces Servlet: PWC1406: Servlet.service() for servlet Faces Servlet threw exception java.lang. IllegalStateException at com.sun.faces.context.
FacesContextImpl. AssertNotReleased(FacesContextImpl. Java:639) at com.sun.faces.context.
FacesContextImpl. GetCurrentPhaseId(FacesContextImpl. Java:515) at javax.faces.event.
ExceptionQueuedEventContext.(ExceptionQueuedEventContext. Java:148) at javax.faces.event. ExceptionQueuedEventContext.(ExceptionQueuedEventContext.
Java:101) at com.sun.faces.lifecycle.Phase. QueueException(Phase. Java:156) at com.sun.faces.lifecycle.Phase.
QueueException(Phase. Java:149) at com.sun.faces.lifecycle.Phase. DoPhase(Phase.
Java:109) at com.sun.faces.lifecycle.LifecycleImpl. Execute(LifecycleImpl. Java:118) at javax.faces.webapp.FacesServlet.
Service(FacesServlet. Java:312) at org.apache.catalina.core.StandardWrapper. Service(StandardWrapper.
Java:1523) at org.apache.catalina.core. ApplicationFilterChain. InternalDoFilter(ApplicationFilterChain.
Java:343) at org.apache.catalina.core. ApplicationFilterChain. DoFilter(ApplicationFilterChain.
Java:215) at filters. RestrictPageFilter. DoFilter(RestrictPageFilter.
Java:90) at org.apache.catalina.core. ApplicationFilterChain. InternalDoFilter(ApplicationFilterChain.
Java:256) at org.apache.catalina.core. ApplicationFilterChain. DoFilter(ApplicationFilterChain.
Java:215) at org.apache.catalina.core. StandardWrapperValve. Invoke(StandardWrapperValve.
Java:277) at org.apache.catalina.core. StandardContextValve. Invoke(StandardContextValve.
Java:188) at org.apache.catalina.core. StandardPipeline. Invoke(StandardPipeline.
Java:641) at com.sun.enterprise.web.WebPipeline. Invoke(WebPipeline. Java:97) at com.sun.enterprise.web.
PESessionLockingStandardPipeline. Invoke(PESessionLockingStandardPipeline. Java:85) at org.apache.catalina.core.
StandardHostValve. Invoke(StandardHostValve. Java:185) at org.apache.catalina.connector.CoyoteAdapter.
DoService(CoyoteAdapter. Java:325) at org.apache.catalina.connector.CoyoteAdapter. Service(CoyoteAdapter.
Java:226) at com.sun.enterprise. V3.services.impl.ContainerMapper. Service(ContainerMapper.
Java:165) at com.sun.grizzly.http.ProcessorTask. InvokeAdapter(ProcessorTask. Java:791) at com.sun.grizzly.http.ProcessorTask.
DoProcess(ProcessorTask. Java:693) at com.sun.grizzly.http.ProcessorTask. Process(ProcessorTask.
Java:954) at com.sun.grizzly.http. DefaultProtocolFilter. Execute(DefaultProtocolFilter.
Java:170) at com.sun.grizzly. DefaultProtocolChain. ExecuteProtocolFilter(DefaultProtocolChain.
Java:135) at com.sun.grizzly. DefaultProtocolChain. Execute(DefaultProtocolChain.
Java:102) at com.sun.grizzly. DefaultProtocolChain. Execute(DefaultProtocolChain.
Java:88) at com.sun.grizzly.http. HttpProtocolChain. Execute(HttpProtocolChain.
Java:76) at com.sun.grizzly. ProtocolChainContextTask. DoCall(ProtocolChainContextTask.
Java:53) at com.sun.grizzly. SelectionKeyContextTask. Call(SelectionKeyContextTask.
Java:57) at com.sun.grizzly.ContextTask. Run(ContextTask. Java:69) at com.sun.grizzly.util.
AbstractThreadPool$Worker. DoWork(AbstractThreadPool. Java:330) at com.sun.grizzly.util.
AbstractThreadPool$Worker. Run(AbstractThreadPool. Java:309) at java.lang.Thread.
Run(Thread. Java:662) Update @ManagedBean @ViewScoped public class SecurityController { @EJB private IAuthentificationEJB authentificationEJB; private String email; private String password; private String notificationValue; public String logOut() { HttpSession session = (HttpSession) FacesContext. GetCurrentInstance().
GetExternalContext(). GetSession(false); if (session! = null) { session.invalidate(); } return "main.
Xhtml"; } ... } java jsf java-ee jsf-2.0 primefaces link|improve this question edited Apr 20 '11 at 10:46 asked Apr 20 '11 at 9:58sfrj2,672948 100% accept rate.
I don't know if you need the release() method. I think this method is the reason for your exception. A quote from the javadoc: After release() is called on a FacesContext instance (until the FacesContext instance has been recycled by the implementation for re-use), calling any other methods will cause an IllegalStateException to be thrown.
... The implementation must call setCurrentInstance(javax.faces.context. FacesContext) passing null to remove the association between this thread and this dead FacesContext instance. I use the following logout method.
Maybe this is helpful for you: public String logout() { HttpSession session = (HttpSession) FacesContext. GetCurrentInstance(). GetExternalContext().
GetSession(false); if (session! = null) { session.invalidate(); } user = null; // reset user // optional: addSuccessMessage return "login"; }.
I modified my code at the managed bean(update above) to look like yours, now I don't see the exception. I manually navigate to other pages and it looks like session is correctly invalidated. It works fine, just I don't get redirect to main.
Xhtml why? – sfrj Apr 20 '11 at 10:52.
Try changing from RequestScoped to for example Sessions, I've had some trouble in the apst with RequestScoped backing beans.
When I put sessionScoped I cant run the app, it says: org.glassfish.deployment.common. DeploymentException: WELD-000072 Managed bean declaring a passivating scope must be passivation capable. – sfrj Apr 20 '11 at 10:15 When I use ViewScoped I can build but I have the same exception.
What other options do I have? That managed bean should not be applicationScopped – sfrj Apr 20 '11 at 10:21.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.