Cewolf FAQ

FAQ Revised: Monday 09 June 2003 23:18:38

Table of Contents

1. General
2. Troubleshooting

1. General

1.1. What is the purpose of Cewolf?
Cewolf enables web applications running in a servlet container to easily include chart images.

1.2. Who wrote it?
Guido Laures wrote the initial program and released it.

1.3. Why has Cewolf been developped?
While developing a web application which needed to provide some chart images Guido found out that there is no open source library which provides the ability to define chart images as JSP tags. So he started to write a simple tag library based on the famous JFreeChart library for standalone chart images.
In June 2002 Guido decided to donate his library to the public and named it Cewolf.

2. Troubleshooting

2.1. I'm using Cewolf under Unix/Linux. When trying to access a chart I get a NoClassDefFoundError. What am I doing wrong?
Essentially, this is a variation of the headless Linux server problem. If there are any Linux wizards out there (I use SuSE 7.1) to point out better solutions, I'd be happy to hear them.
I was not quite convinced it would be the same problem many other people had, since I _have_ an X server running. However, it is sitting there, idling away with KDM (the KDE Display Manager), and I could not find a way to make that display available to java. I tried to connect to it, tried to set xhost +, but no avail. In the end, I used (as root) startx -- :2 to start another X server on display :2 (localhost is implied). Unfortunately, startx will start KDE, so the libraries are loaded into memory, but that is a minor annoyance. There might be a possibility of starting just the X server or a minor window manager (twm for example), but I tried with env WANTEDWM=twm startx -- :2 &, but KDE got loaded anyway. In essence, the Xvfb solution might just be the thing I use next time.
Then, all you have to do is tell Tomcat to use display 2 for painting: env DISPLAY=:2 bin/startup.sh (being in /opt/tomcat4).
Other posts I found helpful were: http://www.object-refinery.com/phorum-3.3.2a/read.php?f=2&i=2987&t=2987 http://forum.java.sun.com/thread.jsp?forum=4&thread=201773 http://forum.java.sun.com/thread.jsp?forum=20&thread=132877
Generally, try to look for 'headless' on java.sun.com (be sure to include the forums!).
Why didn't I use the headless option of JDK1.4? Of course I tried, but the Cewolf classes include a call to de.laures.cewolf.util.ImageHelper, which in its static initializer will throw a headless exception. I verified this under NT and Linux. :(
One good method to troubleshoot is to call the servlet directly: in IE, right-click on the image (presumably missing, otherwise you wouldn't be here...), choose Properties, select the whole path and copy the path into the address line. Call this, and you will get a stack trace detailing the problem. However, it might be necessary to reload the application in between - somehow, only the stack trace of the first call is useful, the next calls to the same servlet will result in a much more generic (bland) error message.
With the method above I was able to use the Cewolf.war files from versions 0.7, 0.8 and 0.8.1. However, only the testpage worked satisfyingly in all cases. The Cewolf set in some circumstances created a
java.lang.ClassCastException: sun.awt.image.DataBufferNative
at sun.awt.image.codec.JPEGImangeEncoderImpl.encode(lines 405, called from 228 and 235)
at de.laures.cewolf.taglib.Renderer.renderLegend(Renderer.java:97)
at de.laures.cewolf.taglib.LegendTag.doStartTag(LegendTag.java:56)
at org.apache.jsp.cewolfset_jsp. and so on........
This is in 0.8.1. In the cewolfset of 0.7, most charts render fine, except for the last two, where it says 'Separate legend befor chart rendering' [sic] and 'Pie Chart with separate legend after chart rendering'. Both charts render fine, but the legends don't. Using above mentioned technique to render the servlet alone (the path is localhost:8080/Cewolf-0.7/cewolf?id=pie&action=renderlegend), the known ClassCastException appears again.
The one thing I still don't get is why my own application does not work on Linux, even though I use the exact same war file on NT without problems. I just get the empty windows, no stack traces in any logs, and calling the servlets alone gets the ClassCastException again, even though I don't think I do anything differently than in the testpage code. I just tried to do it under JDK1.4.1_01, but no change (except that the ClassCastException doesn't mention sun.awt.image.DataBufferNative anymore). JDK1.3 might work (I get to see the complete Cewolfset, including the legends), only that I get another error in my DataProvider in a call to Calendar.setTimeInMillis (was protected in 1.3 and is public in 1.4). This error message was what prompted me to switch over to 1.4 in the first place... But I can fix that. Or wait until the casting problem is solved.

2.2. Why does the same chart display again and again even though the data changes?
A DatasetProducer is supposed to generate the same data when passed in the same paramters. So Cewolf returns a cached instance of a chart if there is no change in parameters. If your DatasetProducer produces different data even when parameters do not change you can add a fake parameter (e.g. time) to avoid caching.
Since verion 0.9 this issue has been fixed with the new methods in the DatasetProducer interface.

Copyright (c) 2003 Guido Laures
This list of questions and answers was generated by makefaq.