Thanks,
I have to realize I want too much.

With the proposed approach I have to maintain a global map to be able to
iterate through all active context from different sessions.
It can be done, but I don't see how to manage this map on an other node on
session failover. My plan was to simply rely on session replication to
support clustering my context.
Now it seems I can target distribution of my context on top of session
replication, or handle session expiration upon undeploy, but not both. At
least with a reasonable amount of work.
Life is hard :)
I am going to target distribution instead, and log a warning on failed
destroy.



2017-02-26 18:42 GMT+01:00 Romain Manni-Bucau <rmannibu...@gmail.com>:

> Yep - side note: session expiration is portable, not undeploy
>
> Le 26 févr. 2017 17:38, "Tamás Kimmel" <kumm0...@gmail.com> a écrit :
>
> Thanks Romain!
>
> I'm trying to interpret it.
> There is no portable way to destroy a custom CDI context on session
> expiration. It's implementation specific whether CDI is up while session
> expires upon undeploy.
> - even session expiration upon node shutdown is implementation, and
> configuration specific in a distributed environment. Tomcat for example
> expires sessions locally on node, did not check others  -
>
> Best I can do:
> - introduce a flag ( for example a system property )
> - observe @BeforeShutdown
> - from observer iterate through all active contexts, and destroy them. Or
> just skip it according to the flag.
>
> Am I understand it right?
>
>
> 2017-02-26 13:24 GMT+01:00 Romain Manni-Bucau <rmannibu...@gmail.com>:
>
> > Yes, depends the session manager impl there. It has several pitfalls like
> > breaking distribution etc so best is to remove it likely through a flag
> and
> > observe shutdown event for the final destruction if needed.
> >
> >
> > Le 26 févr. 2017 12:48, "Tamás Kimmel" <kumm0...@gmail.com> a écrit :
> >
> > > Hi, I'm implementing a custom CDI context storing itself in session.
> > > On session expiration my context should destroy all active contextual
> > > instances.
> > >
> > > I've run into an issue after turned off session serialization.
> > > ( with a context.xml contains <Manager pathname="" />)
> > >
> > > Upon undeploy tomcat expires all sessions ( as it should ), but I get
> an
> > > exception.
> > > beanManager.getPassivationCapableBean can't find my bean, and it
> causes
> > an
> > > NPE in deltaspike AbstractContext.destroyBean.
> > > It seems to me application beans are undeployed already when session
> > > expiration event fired. I've found even my context is lost at this
> point,
> > > beanManager.getContext() fails.
> > >
> > > An example project can be found here: https://github.com/kumm/
> > mycdicontext
> > > 'mvn test' is green but predestroy don't run ('++ HelloBean preDestroy
> > ++'
> > > should appear in the log), and exception is logged.
> > >
> > > Running with -Pwildfly, or -Pglassfish it's working.
> > > Maybe it's something implementation specific and my approach is wrong?
> > >
> > > Thanks in advance,
> > > Kimmel Tamás
> > >
> > > Stacktrace below:
> > >
> > > 26-Feb-2017 12:03:28.209 INFO [http-nio-8080-exec-6]
> > > org.apache.openejb.assembler.classic.Assembler.destroyApplication
> > > Undeploying app:
> > > /home/kumm/Workspace/Projects/tomeecditest/target/tomee/wd/
> > > 0/eb577be1-a135-4f7d-bd6e-01ea88695d21
> > > 26-Feb-2017 12:03:28.216 SEVERE [http-nio-8080-exec-6]
> > > org.apache.webbeans.component.AbstractOwbBean.destroy Exception thrown
> > > while destroying bean instance : [StorageRepository,
> > WebBeansType:MANAGED,
> > > Name:null, API
> > > Types:[java.lang.Object,java.io.Serializable,trial.
> mycontext.MyContext$
> > > StorageRepository],
> > > Qualifiers:[javax.enterprise.inject.Default,javax.
> > enterprise.inject.Any]]
> > >  java.lang.NullPointerException
> > >     at
> > > org.apache.deltaspike.core.util.context.AbstractContext.
> > > destroyBean(AbstractContext.java:202)
> > >     at
> > > org.apache.deltaspike.core.util.context.AbstractContext.
> > destroyAllActive(
> > > AbstractContext.java:195)
> > >     at
> > > trial.mycontext.MyContext$StorageRepository.destroy(MyContext.java:60)
> > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >     at
> > > sun.reflect.NativeMethodAccessorImpl.invoke(
> > NativeMethodAccessorImpl.java:
> > > 62)
> > >     at
> > > sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > > DelegatingMethodAccessorImpl.java:43)
> > >     at java.lang.reflect.Method.invoke(Method.java:497)
> > >     at
> > > org.apache.webbeans.intercept.LifecycleInterceptorInvocation
> > > Context.proceed(LifecycleInterceptorInvocationContext.java:103)
> > >     at
> > > org.apache.webbeans.portable.InjectionTargetImpl.preDestroy(
> > > InjectionTargetImpl.java:352)
> > >     at
> > > org.apache.webbeans.component.AbstractOwbBean.destroy(
> > > AbstractOwbBean.java:179)
> > >     at
> > > org.apache.webbeans.context.AbstractContext.destroyInstance(
> > > AbstractContext.java:206)
> > >     at
> > > org.apache.webbeans.context.AbstractContext.destroyInstance(
> > > AbstractContext.java:192)
> > >     at
> > > org.apache.webbeans.context.AbstractContext.destroy(
> > > AbstractContext.java:218)
> > >     at
> > > org.apache.webbeans.web.context.WebContextsService.
> > destroySessionContext(
> > > WebContextsService.java:547)
> > >     at
> > > org.apache.webbeans.web.context.WebContextsService.
> > > endContext(WebContextsService.java:227)
> > >     at
> > > org.apache.openejb.server.httpd.BeginWebBeansListener.
> sessionDestroyed(
> > > BeginWebBeansListener.java:170)
> > >     at
> > > org.apache.catalina.session.StandardSession.expire(
> > > StandardSession.java:824)
> > >     at
> > > org.apache.catalina.session.StandardSession.expire(
> > > StandardSession.java:766)
> > >     at
> > > org.apache.catalina.session.StandardManager.stopInternal(
> > > StandardManager.java:396)
> > >     at org.apache.catalina.util.LifecycleBase.stop(
> > LifecycleBase.java:226)
> > >     at
> > > org.apache.catalina.core.StandardContext.stopInternal(
> > > StandardContext.java:5407)
> > >     at org.apache.catalina.util.LifecycleBase.stop(
> > LifecycleBase.java:226)
> > >     at
> > > org.apache.catalina.core.ContainerBase.removeChild(
> > ContainerBase.java:815)
> > >
> >
>

Reply via email to