0.9.17 not working in web app
0.9.17 not working in web app
I've just tried upgrading to 0.9.17 from 0.9.16 for a web app (i.e. a servlet). I am not getting any output from the servlet now and not seeing any error messages either. I've added log4j to the classpath and configured it in the servlet. (I've tried setting the logging level to ALL - a lot of messages written to the log but no errors.) And there are no previous version of any jfreechart libraries in the classpath. I've managed to cope with all the changes over the last 13 releases but this one has me stumped. :) Anyone can tell me what I've overlooked in the upgrade?
0.9.17 not working in web app
I've found out a bit more. I went through the source and commented out all references to log4j. Now when I try to run my web app I get the following error when attempting to create a chart:
java.lang.IllegalStateException: getOutputStream() has already been called for this response
Now what could have changed from 0.9.16 to 0.9.17 that would cause this? (I'm not necessarily saying the problem is with jfreechart - the change could just as well have exposed a bug in my servlet.)
java.lang.IllegalStateException: getOutputStream() has already been called for this response
Now what could have changed from 0.9.16 to 0.9.17 that would cause this? (I'm not necessarily saying the problem is with jfreechart - the change could just as well have exposed a bug in my servlet.)
I don't know if this is related to your issue, but I also had problems upgrading to 0.9.17. I don't think it was the same exception as yours but some exception was being thrown whenever I tried to generate a chart.
To correct the problem, I had to upgrade jcommon from 0.9.1 to 0.9.2. The link for jcommon off the jfreechart site is not up to date, but if check the dir where you untarred JFC 0.9.17 you should find the correct jcommon jar.
What's weird is supposedly everything you need for JFC is included in the jfreechart jar, but I had to deploy the jcommon jar seperately to get it to work. Might be worth a try for your problem...
To correct the problem, I had to upgrade jcommon from 0.9.1 to 0.9.2. The link for jcommon off the jfreechart site is not up to date, but if check the dir where you untarred JFC 0.9.17 you should find the correct jcommon jar.
What's weird is supposedly everything you need for JFC is included in the jfreechart jar, but I had to deploy the jcommon jar seperately to get it to work. Might be worth a try for your problem...
-
- Posts: 115
- Joined: Fri Mar 14, 2003 3:13 pm
- Location: London, England
- Contact:
0.9.17 Web App Support
I've just updated the sample WAR file and that works alright (on Tomcat at least). You may want to take a look at the code and try and spot differences.
Regards,
Richard...
Regards,
Richard...
0.9.17 not working in web app
More info - I have been using ChartUtilities.writeChartAsJPEG and that does not work with 0.9.17. However I just tried ChartUtilities.writeChartAsPNG and that does work. To confirm this I tried running the ServletDemo1 from the premium demos, it also works as PNG but not as JPEG.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
My guess is that the problem is caused by a change in the createBufferedImage() method in the JFreeChart class. The image type is now BufferedImage.TYPE_INT_ARGB (the change was to enable transparency in PNG output), perhaps that breaks the JPEG encoder (which I don't recommend using anyway).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


I observed similiar problems creating JPG images. The webapp wouldn't display the image. If I created the file manually, my image viewer showed it "yellowed". The image was there but it appeared like I was looking at it through an orange-yellow filter. I saw the TYPE_INT_ARGB change; when I changed it back to its original value (TYPE_INT_RGB), my image was displayed correctly. Due to other issues found (and discussed in other threads), I left the changes there and went back to 0.9.16.
So it appears that the change to enable PNG transparency may break the JPEG encoder. Are there any options that would allow the necessary PNG transparency and keep the JPEG encoder working? If the two are mutually exclusive and you do not recommend the JPEG encoder, might it be necessary to drop JPEG support from JFreeChart?
So it appears that the change to enable PNG transparency may break the JPEG encoder. Are there any options that would allow the necessary PNG transparency and keep the JPEG encoder working? If the two are mutually exclusive and you do not recommend the JPEG encoder, might it be necessary to drop JPEG support from JFreeChart?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
For 0.9.18, I have added a new createBufferedImage() method to the JFreeChart class that allows the image type to be specified. So now the PNG export can use BufferedImage.TYPE_INT_ARGB and the JPEG export can use BufferedImage.TYPE_INT_RGB. That should resolve the problem.
As an aside, JPEG is not a great format for saving charts - it is a "lossy" format and introduces visible artifacts into the charts. PNG is a "lossless" format so the charts will be reproduced perfectly. Always use PNG ahead of JPEG unless you have a good reason not to (I can't think of one, but who knows, there may be one).
As an aside, JPEG is not a great format for saving charts - it is a "lossy" format and introduces visible artifacts into the charts. PNG is a "lossless" format so the charts will be reproduced perfectly. Always use PNG ahead of JPEG unless you have a good reason not to (I can't think of one, but who knows, there may be one).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


PNG & JPEG
So when is 0.9.18 going to be released, David?