"ragavgomatam" wrote : Yes..Try it..This should do a Jaas Log out for you
ragavgomatam, I've tried with the code:
| HttpSession session =
| (HttpSession) FacesContext.getCurrentInstance().
| getExternalContext().getSession(false);
| session.invalidate();
|
but unfortunately it doesn't work because at this point in the web life cycle when the
web container calls the method marked with the @PreDestroy annotation to do the cleanup,
FacesContext.getCurrentInstance() returns null. So, I get the following exception:
| 2008-08-12 08:26:37,343 ERROR
[org.jboss.web.jsf.integration.injection.JBossInjectionProvider] PreDestroy failed on
managed bean.
| java.lang.reflect.InvocationTargetException
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at
org.apache.catalina.util.DefaultAnnotationProcessor.preDestroy(DefaultAnnotationProcessor.java:112)
| at
org.jboss.web.jsf.integration.injection.JBossInjectionProvider.invokePreDestroy(JBossInjectionProvider.java:80)
| at com.sun.faces.mgbean.BeanBuilder.destroy(BeanBuilder.java:120)
| at com.sun.faces.mgbean.BeanManager.destroy(BeanManager.java:248)
| at
com.sun.faces.application.WebappLifecycleListener.handleAttributeEvent(WebappLifecycleListener.java:265)
| at
com.sun.faces.application.WebappLifecycleListener.sessionDestroyed(WebappLifecycleListener.java:133)
| at
com.sun.faces.config.ConfigureListener.sessionDestroyed(ConfigureListener.java:296)
| at org.apache.catalina.session.StandardSession.expire(StandardSession.java:702)
| at org.apache.catalina.session.StandardSession.expire(StandardSession.java:660)
| at org.apache.catalina.session.StandardManager.stop(StandardManager.java:676)
| at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4523)
| at org.apache.catalina.core.ContainerBase.destroy(ContainerBase.java:1163)
| at org.apache.catalina.core.StandardContext.destroy(StandardContext.java:4617)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at
org.jboss.web.tomcat.service.TomcatDeployer.performUndeployInternal(TomcatDeployer.java:461)
| at
org.jboss.web.tomcat.service.TomcatDeployer.performUndeploy(TomcatDeployer.java:432)
| at org.jboss.web.AbstractWebDeployer.stop(AbstractWebDeployer.java:422)
| at org.jboss.web.WebModule.stopModule(WebModule.java:100)
| at org.jboss.web.WebModule.stopService(WebModule.java:66)
| at
org.jboss.system.ServiceMBeanSupport.jbossInternalStop(ServiceMBeanSupport.java:315)
| at
org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:247)
| at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at
org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| at $Proxy0.stop(Unknown Source)
| at org.jboss.system.ServiceController.stop(ServiceController.java:508)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy44.stop(Unknown Source)
| at org.jboss.web.AbstractWebContainer.stop(AbstractWebContainer.java:498)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
| at
org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
| at
org.jboss.wsf.container.jboss42.DeployerInterceptor.stop(DeployerInterceptor.java:98)
| at
org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.stop(SubDeployerInterceptorSupport.java:196)
| at
org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:99)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy45.stop(Unknown Source)
| at org.jboss.deployment.MainDeployer.stop(MainDeployer.java:667)
| at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:638)
| at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:632)
| at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:615)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy9.undeploy(Unknown Source)
| at
org.jboss.deployment.scanner.URLDeploymentScanner.undeploy(URLDeploymentScanner.java:450)
| at
org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:604)
| at
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
| at
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
| at
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
| Caused by: java.lang.NullPointerException
| at br.urca.www.biblioteca.dados.ejb.AutenticacaoEJB.logout(AutenticacaoEJB.java:34)
| at br.urca.www.biblioteca.web.PesquisaAcervo.finalizar(PesquisaAcervo.java:60)
| ... 96 more
| 2008-08-12 08:26:37,343 ERROR
[org.jboss.web.jsf.integration.injection.JBossInjectionProvider] PreDestroy failed on
managed bean.
| java.lang.reflect.InvocationTargetException
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at
org.apache.catalina.util.DefaultAnnotationProcessor.preDestroy(DefaultAnnotationProcessor.java:112)
| at
org.jboss.web.jsf.integration.injection.JBossInjectionProvider.invokePreDestroy(JBossInjectionProvider.java:80)
| at com.sun.faces.mgbean.BeanBuilder.destroy(BeanBuilder.java:120)
| at com.sun.faces.mgbean.BeanManager.destroy(BeanManager.java:248)
| at
com.sun.faces.application.WebappLifecycleListener.handleAttributeEvent(WebappLifecycleListener.java:265)
| at
com.sun.faces.application.WebappLifecycleListener.attributeRemoved(WebappLifecycleListener.java:189)
| at
com.sun.faces.config.ConfigureListener.attributeRemoved(ConfigureListener.java:333)
| at
org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1670)
| at org.apache.catalina.session.StandardSession.expire(StandardSession.java:756)
| at org.apache.catalina.session.StandardSession.expire(StandardSession.java:660)
| at org.apache.catalina.session.StandardManager.stop(StandardManager.java:676)
| at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4523)
| at org.apache.catalina.core.ContainerBase.destroy(ContainerBase.java:1163)
| at org.apache.catalina.core.StandardContext.destroy(StandardContext.java:4617)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at
org.jboss.web.tomcat.service.TomcatDeployer.performUndeployInternal(TomcatDeployer.java:461)
| at
org.jboss.web.tomcat.service.TomcatDeployer.performUndeploy(TomcatDeployer.java:432)
| at org.jboss.web.AbstractWebDeployer.stop(AbstractWebDeployer.java:422)
| at org.jboss.web.WebModule.stopModule(WebModule.java:100)
| at org.jboss.web.WebModule.stopService(WebModule.java:66)
| at
org.jboss.system.ServiceMBeanSupport.jbossInternalStop(ServiceMBeanSupport.java:315)
| at
org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:247)
| at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at
org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| at $Proxy0.stop(Unknown Source)
| at org.jboss.system.ServiceController.stop(ServiceController.java:508)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy44.stop(Unknown Source)
| at org.jboss.web.AbstractWebContainer.stop(AbstractWebContainer.java:498)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
| at
org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
| at
org.jboss.wsf.container.jboss42.DeployerInterceptor.stop(DeployerInterceptor.java:98)
| at
org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.stop(SubDeployerInterceptorSupport.java:196)
| at
org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:99)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy45.stop(Unknown Source)
| at org.jboss.deployment.MainDeployer.stop(MainDeployer.java:667)
| at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:638)
| at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:632)
| at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:615)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy9.undeploy(Unknown Source)
| at
org.jboss.deployment.scanner.URLDeploymentScanner.undeploy(URLDeploymentScanner.java:450)
| at
org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:604)
| at
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
| at
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
| at
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
| Caused by: java.lang.NullPointerException
| at br.urca.www.biblioteca.dados.ejb.AutenticacaoEJB.logout(AutenticacaoEJB.java:34)
| at br.urca.www.biblioteca.web.PesquisaAcervo.finalizar(PesquisaAcervo.java:60)
|
I placed System.out.println calls and I saw that really FacesContext.getCurrentInstance()
is returning null at this point. In my application there's not a logout button or
whatever for the user to logout. All this is happening when I'm redeploying the
application to the server, and the server is in the process of shutting down the old
application that was running.
This application that I'm developing doesn't have to have any security
restrictions. I mean, everyone could access it and I don't need to secure my EJBs
restricting access to some roles. So, I was wondering as I'm able to make EJB calls
without authentication (as was shown previously), wouldn't be ok to just proceed like
this? I think that when I don't provide an authenticated user to JBoss, it is using
something like this behind the scenes automatically for me (correct me if I'm wrong),
if not I wouldn't be able to make method calls. So, if JBoss releases the resources it
allocates when the session expires, it would be ok for me. So, what do you have to tell me
about this? How JBoss behave in this case? Is this a good approach for me to follow? If
not, what would be another place for me to do the logout from the WebAutentication
facility?
Thank you.
Marcos
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170053#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...