In-line responses.  Thanks for the ideas, I really do appreciate it.

On Thu, Feb 16, 2012 at 10:43 AM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Gregory,
>
> On 2/16/12 10:34 AM, Gregory Werner wrote:
> > I didn't know that either.  It is simply a case of looking for the
> > wrong keywords.  I said application score replication they said
> > context attribute replication.  I gotta learn how to speak their
> > language.
> >
> > Even after I put <Context
> > className="*org.apache.catalina.ha.context.ReplicatedContext*"> in
> > my context.xml
> >
> > and make sure that my application's web.xml has *<distributable
> > />* * * the following:
> >
> > 1. Map<String, Date> userCache = (Map<String, Date>)
> > context.getAttribute("userCache"); 2.
> > userCache.remove(remoteUserName);
> >
> > returns a null userCache object (context is set in the
> > ServletContextAware method, setServletContext).
>
> Is this all on the same server, or are you setting the attribute in
> one context and watching for it's value to be available in a different
> (replicated) one?
>
>
In this case it is a test environment.  We are trying to emulate two
distinct physical servers/load-balancing (which is the real case) on a
single physical machine with one Tomcat instance.  Looking at the logs we
can see some requests going to A and some going to B so it is load
balancing, but in the end I am only placing a single war file and starting
a single tomcat instance.


> Just trying to understand the test case, here.
>
> > When I enumerate through all the context attributes, I cannot see
> > the stuff I am putting in it, just like the default entries which
> > wind up there.  Too weird.
>
> Remember that it's not magic replication: Tomcat doesn't know when you
> modify the object itself. I suspect that if you modify the object
> itself (say, by adding elements to the cache) you'll have to do this:
>
> context.setAttribute("userCache", userCache);
>

I do, that would be my next line.  I just stopped there because the
userCache I retrieve from the context is null so I get a
NullPointerException crashing things before I get an opportunity to put it
back in the cache.


>
> You might want to consider using something like memcached or even a
> traditional database to share this kind of information: IMO they are
> much better equipped to do the kinds of things you want to do (and
> they are separated from the servlet API, which can either be a good
> thing or a bad thing for you).
>
> - -chris
>

Reply via email to