well the point is today you can configure session strategy, stateful
one but not CDI one. There is no global persist option.

clearly something we'll need to have a look (probably next year ;)

the best solution today is to store it in the session

that's said i just looked the code and 2 points:
1) when you shutdown a tomee the application is destroyed so beans too
2) the main point is the implementation of SessionContext whch doesn't
use the session today (that's in OpenWebBeans more than TomEE/OpenEJB)

Nothing important to implement but the point is then it will slow down
your app at runtime...

if you want to try to contribute just hack
org.apache.openejb.cdi.CdiAppContextsService#initSessionContext and
replace the line currentSessionContext = new SessionContext(); by a
session context using the http session

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2012/12/19 bibhas <bibh...@gmail.com>:
> Hi Romain,
>
> Let me explain more. In Tomcat session objects can be persisted on disk so
> that they survive application or server restart. This is configured in
> context.xml by setting a path name:
>
> <Manager pathname="some_path" />
>
> Persistence can be disabled by setting an empty path name. But, by default,
> persistence is enabled in Tomcat and TomEE.
>
>> that's probably not the default everybody expect.
>
> If someone doesn't want session persistence, they can easily disable that.
>
>> then the point is mainly with stateful beans
>
> I am not talking about EJB here. I am talking about plain POJO JavaBeans
> that are managed by CDI. I am not using any entity manager from this bean.
>
> @Named
> @SessionScoped
> public class MyBean implements Serializable {
> ...
> }
>
> I agree that trying to persist a session EJB that uses entity manager can be
> tricky. I won't even try something like that. What I am trying to do is
> persist plain JavaBeans that are in CDI session scope.
>
> The issue that I am trying to point out is that TomEE is being inconsistent.
> When persistence is enabled, regular session objects are persisted but not
> CDI beans. This is causing unnecessary headache for my application, nothing
> that can not be worked around with a bit of code. But, I will like to avoid
> this if possible.
>
> What do I need to do to persist CDI managed JavaBeans that are in session or
> conversation scope?
>
>
>
> --
> View this message in context: 
> http://openejb.979440.n4.nabble.com/TomEE-doesn-t-persist-SessionScoped-beans-tp4659814p4659823.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to