JFreeChart in JBoss Cluster

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
TheHaas
Posts: 21
Joined: Sat Feb 07, 2004 9:14 pm
Contact:

JFreeChart in JBoss Cluster

Post by TheHaas » Thu Apr 01, 2004 4:01 am

Has anyone had any luck with running a JFreeChart application under a clustered JBoss configuration? (i.e. running under "all" instead of "default" server) When I try it, I get a "Not-serializable" exception when the ServletUtilities tries to add ChartDeleter to the HTTPSession. It works fine when running under a non-clustered setup.

richard_atkinson
Posts: 115
Joined: Fri Mar 14, 2003 3:13 pm
Location: London, England
Contact:

Clustering

Post by richard_atkinson » Thu Apr 01, 2004 9:03 pm

The ChartDeleter is not designed to work in a clustered environment as it stores the chart in the local filesystem. You'll need to use a different technique. One possibility would be to just generate the chart twice - once for the image and once for the image map.

Regards,
Richard...

Navarre
Posts: 1
Joined: Thu Jan 27, 2005 7:10 pm
Contact:

timeseriescollections in a clustered tomcat environment

Post by Navarre » Thu Jan 27, 2005 7:23 pm

In my tomcat cluster, I got around the ChartDeleter not being serializable by using Chartutilities instead of Servletutilities to create the JPG and managing the files myself.

However, I am having an issue when I put a TimeSeriesColllection into an HTTpSession that is being replicated across the cluster. It serializes just fine, but when it is read on another cluster I get a classNotFoundException. It is looking for SeriesChangeListener class.

Perhaps it's a bad idea to put my TimeSeriesCollection into session, but I am not sure which way to proceed. Do I persue an alternate method of passing my data around, or do I persue the de-serialization of the ChangeListener?

Any advice would be appreciated.

Vinay Srinivasaiah

solution for the clustering problem, using ServletUtilities

Post by Vinay Srinivasaiah » Wed Apr 20, 2005 7:13 pm

We had a similar situation with tomcat, where we needed to make JFreeChart work in a clustered
environment. Here are the steps and the explanation as to why the changes were made.

Step 1: Make ChartDeleter serializable by implementing java.io.Serializable.

This should not affect any functionality, since the only element in the ChartDeleter is
'java.util.List' which is serializable.

Step 2: Let tomcat know that ChartDeleter changed when a new entry gets added to ChartDeleter.

If you are using DeltaManager in tomcat to replicate only changed attributes, the session might
not get replicated when you create a new chart, since, by design, ServletUtilities only changes
the entries in the ChartDeleter and not the value in the session.

You may have to do the following in your jsp or servlet:

Code: Select all

     ChartDeleter deleter = session.getAttribute("JFreeChart_Deleter");
     session.removeAttribute("JFreeChart_Deleter");
     session.setAttribute("JFreeChart_Deleter", deleter);
Step 3: Again, by design, ChartDeleter deletes all the files when it is decoupled from the
session. Step 2 decouples the "JFreeChart_Deleter" from the session which deletes all the files even
though the session is not invalid. So, make sure the ChartDeleter deletes the files only if
the session is invalid.

Code: Select all

   jfreechart-0.9.21 source snapshot.
    ==== File ChartDeleter.java
    55,56c55
    < public class ChartDeleter implements HttpSessionBindingListener, java.io.Serializable
    < {
    ---
    > public class ChartDeleter implements HttpSessionBindingListener {
    105,108c104
    <         try {
    <             event.getSession().getAttribute("JFreeChart_Deleter");
    <         } catch (IllegalStateException e) {
    <         // remove only if the session is invalidated.
    ---
    >
    117d112
    <         }
    118a114
    >
    119a116
    >
Essentially, in the valueUnbound() method, we call the getAttribute() on the session, which would throw a IllegalStateException if the session is invalid. If the session is not valid, we delete all the files.

We have the above solution working on a cluster of 4 tomcats on our website:

http://www.spikesource.com/spikewatch/i ... platform=5

Comments and feedback welcome.
The above fix is for jfreechart-0.9.21 source snapshot.

Vinay
SpikeSource (http://www.spikesource.com)

Locked