0.9.17 not working in web app

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Mike

0.9.17 not working in web app

Post by Mike » Wed Mar 31, 2004 2:58 am

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?

Mike

0.9.17 not working in web app

Post by Mike » Thu Apr 01, 2004 1:02 am

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.)

admm
Posts: 3
Joined: Sat Mar 27, 2004 1:13 am

Post by admm » Thu Apr 01, 2004 1:15 am

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...

Mike

0.9.17 not working in web app

Post by Mike » Thu Apr 01, 2004 4:40 am

Thanks for the hint - unfortunately it didn't fix things.

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

0.9.17 Web App Support

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

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...

Mike

0.9.17 not working in web app

Post by Mike » Fri Apr 02, 2004 1:19 pm

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.

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 » Fri Apr 02, 2004 4:19 pm

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

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

dbasten
Posts: 52
Joined: Fri Jul 25, 2003 4:29 pm

Post by dbasten » Mon Apr 05, 2004 3:05 pm

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?

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 Apr 05, 2004 10:39 pm

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).
David Gilbert
JFreeChart Project Leader

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

rkhlin
Posts: 10
Joined: Tue Apr 06, 2004 1:12 am

PNG & JPEG

Post by rkhlin » Tue Apr 06, 2004 1:21 am

So when is 0.9.18 going to be released, David?

Locked