M
Michael Brown
We have a Weblogic application that has a data cache stored in several
singleton objects. 99% of the access to the data is via servlets or
JSPs that make data requests which are satisfied from the cache (or
the database, if not available from the cache). There is however one
client that accesses data via RMI and this is causing us some major
problems.
If the RMI client runs single-threaded there's no problem.
Additionally, if the RMI client allows one single-threaded remote call
to complete and then starts going hammer and tongs in multiple
threads, that's also OK and there are no problems. However, if the
RMI client immediately steams in with multiple requests on multiple
(client) threads, it causes a most bizzarre situation to occur: the
next time a *servlet/JSP* request comes in, all our cache singletons
become duplicated, presumably loaded by a second classloader.
The result for our application is catastrophic as the fully populated
cache that existed before is now "hidden" to any servlet/JSP requests
and is loaded all over again, doubling the memory usage and crippling
the performance. RMI requests meantime carry on hitting the
"original" cache.
All the server code (including the RMI remote class) is in the same
..war file so I don't understand why a second classloader is being
used. It's even more strange that it should only occur in this very
specific set of circumstances, namely where the first ever RMI call
has not completed before the second one comes in. If we ensure that
the first RMI call completes before any others occur then from that
point on the server is safe from the problem no matter what.
Fortunately, we have control of the client app so we can work around
the problem but it's concerning that we can't control this problem
from the server side.
Having done a bit of reading on the subject I'm aware that using the
singleton pattern in a J2EE environment is not recommended but quite
frankly, I don't see why. Our app doesn't have any EJBs and it's just
a straightforward web application with a cache of data. There must
necessarily only be one copy of the cache (per server) so I don't see
how this could be done *without* using the singleton pattern. I've
seen suggestions that singleton objects should be registered with JNDI
but that seems like an extraordinary overhead for solving a problem
that shouldn't be arising in the first place. Why would two
classloaders be used only in the very speficic circumstances I've
outlined??
Anyone have any ideas what's going on? BTW, we're using Weblogic
7.0sp4 on Solaris.
Michael.
singleton objects. 99% of the access to the data is via servlets or
JSPs that make data requests which are satisfied from the cache (or
the database, if not available from the cache). There is however one
client that accesses data via RMI and this is causing us some major
problems.
If the RMI client runs single-threaded there's no problem.
Additionally, if the RMI client allows one single-threaded remote call
to complete and then starts going hammer and tongs in multiple
threads, that's also OK and there are no problems. However, if the
RMI client immediately steams in with multiple requests on multiple
(client) threads, it causes a most bizzarre situation to occur: the
next time a *servlet/JSP* request comes in, all our cache singletons
become duplicated, presumably loaded by a second classloader.
The result for our application is catastrophic as the fully populated
cache that existed before is now "hidden" to any servlet/JSP requests
and is loaded all over again, doubling the memory usage and crippling
the performance. RMI requests meantime carry on hitting the
"original" cache.
All the server code (including the RMI remote class) is in the same
..war file so I don't understand why a second classloader is being
used. It's even more strange that it should only occur in this very
specific set of circumstances, namely where the first ever RMI call
has not completed before the second one comes in. If we ensure that
the first RMI call completes before any others occur then from that
point on the server is safe from the problem no matter what.
Fortunately, we have control of the client app so we can work around
the problem but it's concerning that we can't control this problem
from the server side.
Having done a bit of reading on the subject I'm aware that using the
singleton pattern in a J2EE environment is not recommended but quite
frankly, I don't see why. Our app doesn't have any EJBs and it's just
a straightforward web application with a cache of data. There must
necessarily only be one copy of the cache (per server) so I don't see
how this could be done *without* using the singleton pattern. I've
seen suggestions that singleton objects should be registered with JNDI
but that seems like an extraordinary overhead for solving a problem
that shouldn't be arising in the first place. Why would two
classloaders be used only in the very speficic circumstances I've
outlined??
Anyone have any ideas what's going on? BTW, we're using Weblogic
7.0sp4 on Solaris.
Michael.