ChartDeleter.java doesnt implement Serializable Interface

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
sumanseshadri
Posts: 19
Joined: Mon Mar 27, 2006 5:19 am

ChartDeleter.java doesnt implement Serializable Interface

Post by sumanseshadri » Sat Feb 03, 2007 12:35 am

Hi All,
Currently, I am using jfreechart-1.0.1.jar and tomcat 5.5.9. But when I upgraded to tomcat 5.5.20, tomcat throws the following error:

java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute

at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1255)

at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1233)

at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:129)

at org.jfree.chart.servlet.ServletUtilities.registerChartForDeletion(ServletUtilities.java:313)

at org.jfree.chart.servlet.ServletUtilities.saveChartAsPNG(ServletUtilities.java:192)


In version 1.2 of ChartDeleter.java (which is the released part of the jfreechart.jar - 1.0.3) it doesn't implement java.io.Serializable . However,
in 1.2.2.2 which is the second version on the "STABLE_1-0-0" branch it does implement Serializable.

http://jfreechart.cvs.sourceforge.net/j ... a?view=log

So, I would like to know whether a State version (1.0.4) could be available with ChartDeleter.java implementing the Serializable interface. And if yes, it would be nice to know the estimated date.

The only work around now, is to change the following line FROM:

String filename= ServletUtilities.saveChartAsPNG(chart, imageWidth, imageHeight, info, session);

TO:

String filename= ServletUtilities.saveChartAsPNG(chart, imageWidth, imageHeight, info, null);


I think this will result in the chart not being in session and the chart will be generated from scratch everytime, which will slow the performance.

Any information on this is appreciated.

Thank you,
Suman

angel
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Re: ChartDeleter.java doesnt implement Serializable Interfac

Post by angel » Mon Feb 05, 2007 8:41 am

sumanseshadri wrote: I think this will result in the chart not being in session and the chart will be generated from scratch everytime, which will slow the performance.
I will only slow the performance, when you want reuse the chart. But in most cases the image is intended to be actual, so this behavior is disired anyway.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Feb 05, 2007 12:47 pm

ChartDeleter has been made Serializable in CVS, but I'm not sure if that is correct. The purpose of this class is to delete a file (chart image) from the local file system when the user's session expires...it isn't clear to me that this will work in a clustered server environment. In fact, it seems to me that it won't work...but I don't do any server side development work, so perhaps someone else can comment.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Mon Feb 05, 2007 1:04 pm

Hi,

most application server bind a session in a clustered environment to a specific host. But who ever is using the ChartDeleter (or temporary files) in a clustered environment has no clue about safe and sane programming and deserves all the trouble he gets :)

The fix itself makes sure that Tomcat and all other servlet container that try to persist sessions to the disk or database can work with that file.

Btw.: The Servlet spec state that each attribute that is added to a SessionContext *has* to be Serializable. If it's not, it's a violation of the standard.

Regards,
Thomas

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Feb 05, 2007 1:09 pm

Hi Thomas,

Thanks for the follow-up. Given what you've said, I'm happy to leave the Serializable fix in there for the 1.0.4 release (which ought to be out some time this week).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

sumanseshadri
Posts: 19
Joined: Mon Mar 27, 2006 5:19 am

Post by sumanseshadri » Mon Feb 05, 2007 8:09 pm

Thank you all very much for your prompt response. I will check out the 1.0.4 release.

-Suman

Locked