Expierences with CDI clustering?

345 views
Skip to first unread message

Thomas Andraschko

unread,
Feb 16, 2011, 5:53:48 PM2/16/11
to memcached-se...@googlegroups.com
Hi,

has anyone tried to cluster CDI applications?
Today i tried clustering with @SessionScoped CDI beans but it doesn't work.

I also wrote an email to the OWB mailing list, how the beans with CDI
are stored in the session:

"OWB stores @SessionScoped beans in an in-memory map of
SessionContext's that is keyed off the session id.

I believe the FailOverService will later store those SessionContext's
as a session attribute in the session as part of the
FailOverBagWrapper at the end of each request. It should then
serialize/restore as appropriate when the session is serialized."

Is there anyone who tried this before?

Thanks :)

Thomas

Martin Grotzke

unread,
Feb 16, 2011, 6:20:54 PM2/16/11
to memcached-se...@googlegroups.com
Hi Thomas,

which msm serialization strategy are you using? Have you tried java
serialization?

Cheers,
Martin

--
Martin Grotzke
http://www.javakaffee.de/blog/

Martin Grotzke

unread,
Feb 16, 2011, 6:32:02 PM2/16/11
to memcached-se...@googlegroups.com
Another question: are you still using non-sticky sessions?

Cheers,
Martin

Martin Grotzke

unread,
Feb 17, 2011, 3:44:09 AM2/17/11
to memcached-se...@googlegroups.com
If you're using non-sticky sessions you can try the attached msm jar
(with java serialization and tc7), it contains additional support for
HttpSessionActivationListener for non-sticky sessions (AFAICS OWB uses
HSAL for FailOverBag). However, I would be really surprised if this
would already do the trick ;-)

Cheers,
Martin


On Thu, Feb 17, 2011 at 12:32 AM, Martin Grotzke

memcached-session-manager-tc7-1.4.0-SNAPSHOT.jar

Thomas Andraschko

unread,
Feb 17, 2011, 3:45:51 AM2/17/11
to memcached-se...@googlegroups.com
Hi,

i still using Non-Sticky sessions and Kyro serialization. I will try
to use Java serialization this morning.

Thomas

2011/2/17 Martin Grotzke <martin....@googlemail.com>:

Thomas Andraschko

unread,
Feb 17, 2011, 4:04:46 AM2/17/11
to memcached-se...@googlegroups.com
I tried the attached jar and switching to
de.javakaffee.web.msm.JavaSerializationTranscoderFactory but it does
not work :/

2011/2/17 Martin Grotzke <martin....@googlemail.com>:

Martin Grotzke

unread,
Feb 17, 2011, 4:13:11 AM2/17/11
to memcached-se...@googlegroups.com
Probably you also need to change your openwebbeans.properties to
org.apache.webbeans.web.failover.issupportfailover=true
org.apache.webbeans.web.failover.issupportpassivation=true

If this does also not work I suggest that you put together a simple
sample of what you're trying to do as a clone of
https://github.com/magro/msm-sample-webapp/tree/simpleservlet
on github so that we can check together what's missing for OWB support.

Cheers,
Martin

Thomas Andraschko

unread,
Feb 17, 2011, 4:49:07 AM2/17/11
to memcached-se...@googlegroups.com
I tried to add this properties but it does not work.
I attached a simple Maven project with Myfaces & OpenWebBeans.
Open the /test.xhml in your browser, the first value will be stored in
the @SessionScoped bean and the second value will be stored in the
SessionMap.
I hope it's ok :)


Thomas

2011/2/17 Martin Grotzke <martin....@googlemail.com>:

cluster-test.7z

Martin Grotzke

unread,
Feb 17, 2011, 5:08:42 AM2/17/11
to memcached-se...@googlegroups.com
On Thu, Feb 17, 2011 at 10:49 AM, Thomas Andraschko
<zoi...@googlemail.com> wrote:
> I tried to add this properties but it does not work.
> I attached a simple Maven project with Myfaces & OpenWebBeans.
> Open the /test.xhml in your browser, the first value will be stored in
> the @SessionScoped bean and the second value will be stored in the
> SessionMap.
I have not worked with OWB until now. So that I don't have to dig
through OWB docs how to run with tc7 it would be easier if you provide
a complete archive that I can unpack and run. Or is this already
possible with the provide one? In this case, what do I have to do to
run the app?

Cheers,
Martin

Thomas Andraschko

unread,
Feb 17, 2011, 5:13:54 AM2/17/11
to memcached-se...@googlegroups.com
Its already possible :-) Just run "mvn clean package" and configure
the generated war in tomcat.
I've done it with:
<Context path=""
docBase="C:/cluster-test.war"
debug="0">
... memcached manger
</Context>

2011/2/17 Martin Grotzke <martin....@googlemail.com>:

Martin Grotzke

unread,
Feb 17, 2011, 5:40:03 AM2/17/11
to memcached-se...@googlegroups.com
Ok, deployed it in tomcat 7.0.8 as ROOT.war, but I'm getting a 404
when requesting /test.xhtml.
Is this the same what you experience?

Cheers,
Martin


On Thu, Feb 17, 2011 at 11:13 AM, Thomas Andraschko

Thomas Andraschko

unread,
Feb 17, 2011, 5:46:38 AM2/17/11
to memcached-se...@googlegroups.com
No not really, it should work. Only the replication does not work.
You could also try to simply copy the cluster-test.war to your webapps
directory then the page should be available under
/cluster-test/test.xhtml

Martin Grotzke

unread,
Feb 17, 2011, 6:06:09 AM2/17/11
to memcached-se...@googlegroups.com
On Thu, Feb 17, 2011 at 11:46 AM, Thomas Andraschko
<zoi...@googlemail.com> wrote:
> No not really, it should work. Only the replication does not work.
> You could also try to simply copy the cluster-test.war to your webapps
> directory then the page should be available under
> /cluster-test/test.xhtml
That's exactly what I did before, with the same result. We could now
try to compare the details of the setup, but perhaps it's easier if
you just provide a archive to unpack and run.

Cheers,
Martin

Thomas Andraschko

unread,
Feb 17, 2011, 6:33:59 AM2/17/11
to memcached-se...@googlegroups.com
Thats weird.
I just downloaded a new Tomcat 7.0.8, copied the cluster-test.war
tothe webapps directory, started Tomcat via startup.bat and open the
url
localhost:8080/cluster-test/test.xhtml.
The complete package is to large for googlemail but for sure, this is
a standart Tomcat with the cluster-test.war

Martin Grotzke

unread,
Feb 17, 2011, 8:50:32 AM2/17/11
to memcached-se...@googlegroups.com
Argh, after changing the servlet mapping I saw that the url in my
browser was wrong! Now I get the page.

I realized that failover support was not really activated, as there
are several openwebbeans.properties loaded, and afterwards sorted by
their configuration.ordinal.
Just set it to e.g. 100 and the changes for
org.apache.webbeans.web.failover.issupportfailover and
org.apache.webbeans.web.failover.issupportpassivation will be active.

Unfortunately, now there's a ViewExpiredException:

Feb 17, 2011 2:41:37 PM org.apache.myfaces.shared_impl.util.StateUtils
reconstruct
SEVERE: View State cannot be reconstructed
javax.faces.FacesException: javax.faces.application.ViewExpiredException
at org.apache.myfaces.shared_impl.util.StateUtils.decrypt(StateUtils.java:496)
at org.apache.myfaces.shared_impl.util.StateUtils.reconstruct(StateUtils.java:378)
at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getSavedState(HtmlResponseStateManager.java:213)
at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getState(HtmlResponseStateManager.java:160)
at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreView(DefaultFaceletsStateManagementStrategy.java:148)
at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:388)
at org.apache.myfaces.shared_impl.view.ViewDeclarationLanguageBase.restoreView(ViewDeclarationLanguageBase.java:106)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.restoreView(FaceletViewDeclarationLanguage.java:1438)
at org.apache.myfaces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:278)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:83)
at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:123)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
at org.apache.myfaces.webapp.MyFacesServlet.service(MyFacesServlet.java:108)

Not sure what's the problem here, it will need some debugging to find
the issue or some help from google or the myfaces guys.
For now I need to get back to daily business, if you need any help let me know.

Cheers,
Martin


On Thu, Feb 17, 2011 at 12:33 PM, Thomas Andraschko

Martin Grotzke

unread,
Feb 17, 2011, 7:43:03 PM2/17/11
to memcached-se...@googlegroups.com
Btw, I just had a look at this again and it seems that my cookies were
messed up so that always a new session was created. After cleaning
them there were no more exceptions and the session was
serialized/deserialized correctly AFAICS (on msm level), so that with
1 tomcat the session object was still ok with non-sticky sessions.
Still, after restarting tomcat the session bean was gone / newly
created by OWB. So it seems that there's still s.th. todo.

Cheers,
Martin

Thomas Andraschko

unread,
Feb 18, 2011, 3:50:00 AM2/18/11
to memcached-se...@googlegroups.com
Thanks for your effort!
Yesterday i read somewhere that the beans could not be
clustered/serialized because the ContextualReference would be wrong
but i'm unable to find the link again :/

2011/2/18 Martin Grotzke <martin....@googlemail.com>:

Martin Grotzke

unread,
Feb 18, 2011, 3:56:45 AM2/18/11
to memcached-se...@googlegroups.com
On Fri, Feb 18, 2011 at 9:50 AM, Thomas Andraschko
<zoi...@googlemail.com> wrote:
> Thanks for your effort!
> Yesterday i read somewhere that the beans could not be
> clustered/serialized because the ContextualReference would be wrong
> but i'm unable to find the link again :/
I also just took another 5 minutes to debug this (restarting tomcat
and checking why a new SessionUser instance is created), and right now
my impression is that the bean is not correctly resolved from the
session in this case - sounds somehow similar to what you mention?

Perhaps it's an option to pull in OWB devs to have a look at this?
Otherwise probably it takes some time to understand OWB injection
internals to figure this out.
Perhaps providing a ready to use setup with msm included and a good
description is s.th. they's accept.

Cheers,
Martin

Thomas Andraschko

unread,
Feb 18, 2011, 1:58:26 PM2/18/11
to memcached-se...@googlegroups.com
I saw your comment on the OWB mailing list - I will add the exception
later. I hope we can get it running :)
Another question, did you already used msm with a JSF application?
Yesterday i tried it with 2 tomcats, 1 apache with mod_proxy as
loadbalancer. If do a redirect form page1 to page2, shutdown the
currently used tomcat and use the backbutton, i get an ViewExpired on
the second tomcat :/

2011/2/18 Martin Grotzke <martin....@googlemail.com>:

Martin Grotzke

unread,
Feb 18, 2011, 7:00:39 PM2/18/11
to memcached-se...@googlegroups.com, Thomas Andraschko
Hi Thomas,

I just played with the myfaces-example-simple20-1.1.10.war from
tomahawk-examples-1.1.10-bin
(http://archive.apache.org/dist/myfaces/binaries/) and got the
"Schedule with sample entries" (/schedule1.jsf) to work after adding
USE_ENCRYPTION=false to web.xml:

<context-param>
<param-name>org.apache.myfaces.USE_ENCRYPTION</param-name>
<param-value>false</param-value>
</context-param>

Also after restarting a tomcat the session is picked up correctly, no
exceptions.

Cheers,
Martin


On Fri, Feb 18, 2011 at 7:58 PM, Thomas Andraschko

Reply all
Reply to author
Forward
0 new messages