JFreeChart in JBoss Cluster
JFreeChart in JBoss Cluster
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.
-
- Posts: 115
- Joined: Fri Mar 14, 2003 3:13 pm
- Location: London, England
- Contact:
Clustering
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...
Regards,
Richard...
timeseriescollections in a clustered tomcat environment
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.
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.
solution for the clustering problem, using ServletUtilities
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:
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.
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)
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);
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
>
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)