JFreeChart Problem

Hey all,

I’m having a problem with integrating JFreeChart with Vaadin. I imported everything that I need for creating my chart, and I also imported JFreeChartWrapper jar file that I found in the Add-ons for Vaadin, and everything seemed to be going well.

But when I tried to test if things are working correctly, I had an “HTTP 500” type: Exception Format, and description: the server encountered an internal error () that prevented it from fulfilling this request.

Here is the code for the window that should contain the Chart:

public class JFreeTrial extends Window {
	public JFreeTrial() {
		super("This is a test");
		XYSeries series = new XYSeries("Sprint 1");
		series.add(0, 165);
		series.add(1, 150);
		series.add(2, 130);

		XYSeriesCollection dataset = new XYSeriesCollection();
		// Generate the graph
		JFreeChart chart = ChartFactory.createXYLineChart("Burn Down Chart", // Title
				"days", // x-axis Label
				"Esimated Effort", // y-axis Label
				dataset, // Dataset
				PlotOrientation.VERTICAL, // Plot Orientation
				true, // Show Legend
				true, // Use tooltips
				false // Configure chart to generate URLs?
		JFreeChartWrapper wrapper = new JFreeChartWrapper(chart);
		VerticalLayout v = new VerticalLayout();

So, has anyone encountered this problem before??



Your code looks just fine to me. Do you have any compile problems? Did you include all batik libraries that JFreeChart uses to render SVG charts? What is the detailed error?

At least the ones here should be enough:


I guess you may safely use newer versions of libraries.

Granted that it would be much simpler to have just one jar file for the addon, but there would be a big mess with licensing issues.


Hi Matti !!

Thanks for the quick reply,

No actually I didn’t, any idea where to get those libraries from ??

Here is the detailed error :


javax.servlet.ServletException: Failed to load application class: com.example.jfreechartwithtoolkit.JfreechartwithtoolkitApplication
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.


I’d be lazy and use the link provided in this thread :slight_smile: Or even easier method is to check out the project with command “svn checkout http://dev.vaadin.com/svn/incubator/JFreeChartComponent”.

If you want to download jars from their official sites, google for jfreechart and batik homepages.


Hey Matti !!

I already downloaded the jars provided by the links.

Thanks for your help :slight_smile:



Batik jar files need to be included for deployment are -

(1) batik-awt-util.jar
(2) batik-svggen.jar
(3) batik-util.jar
(4) batik-xml.jar
(5) batik-ext.jar
(6) batik-dom.jar

However, the last 2 files, (5) & (6), can be eliminated by making a slight change in the source code:

                            DOMImplementation domImpl = GenericDOMImplementation
                            Document document = domImpl.createDocument(null,
                                    "svg", null);

Change this to the following because we are using later versions of Java anyway:

                	DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                	DocumentBuilder docBuilder = null;
					try {
						docBuilder = docBuilderFactory.newDocumentBuilder();
					} catch (ParserConfigurationException e1) {
                	Document document = docBuilder.newDocument();


Thanks for the “patch”. I released 2.1 version that has the suggested change + a compression option in case you don’t have global gzip compression on in your server.

Downloadable add-on jar file:



Alternative to batik:
Have a look at this http://www.jfree.org/jfreesvg/
It is very light-weight (only 47K, single jar file) and fast too!


Looks like a potential enhancements to replace batik with that. Batik has a huge set of feature that are not needed in the Vaadin JFreeChart wrapper.

If somebody has performance issues, or otherwise interest to get on the task, I’ll be happy to review changes and build new version.



Its an old thread but I want to use it.


I can get the task of converting batik to freesvg. I’m interested in using this addon.
Note: New versions of JFreeChart uses JFreeSVG, at least in the examples.


I used the above code, dependencies auto-resolved but I cannot see the chart.

When I look to the source, I see this:

GET http://localhost:9191/null 404 (Not Found)

Using Vaadin 7.5.5 and JFreeChart wrapper 3.0.2

any idea?


To use JFreeSVG instead of Batik, I think the actual add-on should be modified. If you haven’t done that use use Batik. IF you are using Maven, the dependencies should be automatically resolved.

BTW. If you can make JFreeSVG version working, I’m happy to review your changes and publish a new version. I moved the sources from the dead code.google.com to



I’ll look for migrating the code to JFreeSVG.

MY problem here, all dependencies are OK but code stops when I add the above JFreeChart code. I get your CRUD example, and after the grid, I added chart.

But I cannot see it, and it also prevent me to see list. When I look to developer console, I see this:

GET http://localhost:8080/null 404 (Not Found) j @ script.js:7 Mj @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:2039 D$c @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5976 Vyb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5849 Kyb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5937 Vxb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5943 Wxb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5637 Txb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5747 oyb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:4661 lxb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5969 Ti @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5025 Li @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:3955 Xi @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5966 Ri @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:996o i @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:2337 ri @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5064 (anonymous function) @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:4602 d @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:441 and the error seem to be on this line on script.js:

function ReplaceVideoElements(){..... any idea ??

Maybe you are hitting the same issue as in
this thread
, a nasty backwards incompatibility introduced in 7.3.9 and still not fixed :frowning:

I’m getting pretty skeptic that our R&D will ever fix that and I have no time for it, so you could maybe introduce the proposed workaround first and only after that look into JFreeSVG upgrade?


Yep, that workaround works perfectly. Thanks.

The only think that worries me for JFreeSVG is its licence, it’s GPL. So it wont be possible to use this addon for commercial products unless open the source !!

Ah, damn GPL :frowning: Maybe it is indeed better to keep at least the default so that it uses Batik.

If you want to contribute a version with the “getResoure workaround”, I’ll be happy to pull it in and build a new release!



Im intend to do this.

Also, there is another problem. Like i said, i used your crud example. But after i add the chart, components after chart are not rendering. There is no error message etc. If ii put chart as first element, the others are not visible.

Also, even if i put it after the List, i cannot ser the list…

What xould be causing this ??


I think the charts kills the rendering loop and all rest components are just not rendered. Fixing the issue will proably take care of this. You can enable client side exceptions by adding “?debug” query parameter to your application during development.



Even if I apply the fix, this issue remains…

XYSeries series = new XYSeries(“Sprint 1”);

    series.add(0, 165);

    series.add(1, 150);

    series.add(2, 130);

    XYSeriesCollection dataset = new XYSeriesCollection();


    // Generate the graph

    JFreeChart chart = ChartFactory.createXYLineChart("Burn Down Chart", // Title

            "days", // x-axis Label

            "Esimated Effort", // y-axis Label

            dataset, // Dataset

            PlotOrientation.VERTICAL, // Plot Orientation

            true, // Show Legend

            true, // Use tooltips

            false // Configure chart to generate URLs?


    JFreeChartWrapper wrapper = new JFreeChartWrapper(chart) {

        private static final long serialVersionUID = 1L;


        public void attach() {


            setResource("src", getSource());





            new MVerticalLayout(

                    new MVerticalLayout(wrapper).withFullWidth(),

                    new RichText().withMarkDownResource("/welcome.md"),

                    new MHorizontalLayout(addNew, edit, delete),




[/code]This is my code, and this is the debug panel:

03msStarting application ROOT-2521314
114msUsing theme: valo
116msVaadin application servlet version: 7.5.0
125msSetting hearbeat interval to 300sec.
132msJSON parsing took 0ms
134msHandling message from server
135ms* Handling resources from server
136ms* Handling type inheritance map from server
140msHandling type mappings from server
143msHandling resource dependencies
145ms* Handling meta information
146ms* Creating connectors (if needed)
166ms* Updating connector states
181ms* Handling locales
184ms* Updating connector hierarchy
186ms* Sending hierarchy change events
204ms* Running @DelegateToWidget
206ms* Sending state change events
220ms* Passing UIDL to Vaadin 6 style connectors
257ms* Performing server to client RPC calls
260ms* Unregistered 0 connectors
261mshandleUIDLMessage: 115 ms
263msStarting layout phase
269msMeasured 3 non connector elements
279msPass 1 measured 8 elements, fired 7 listeners and did 0 layouts.
283msPass 2 measured 3 elements, fired 1 listeners and did 2 layouts.
284msNo more changes in pass 3
295msTotal layout phase time: 31ms
296ms* Dumping state changes to the console
297msUIDL: undefined
325msProcessing time was 192ms for 6108 characters of JSON
326msReferenced paintables: 10
335msStarting layout phase
341msMeasured 3 non connector elements
344msPass 1 measured 2 elements, fired 0 listeners and did 1 layouts.
344msNo more changes in pass 2
346msTotal layout phase time: 10ms
347msStarting layout phase
349msMeasured 3 non connector elements
352msPass 1 measured 2 elements, fired 0 listeners and did 1 layouts.
352msNo more changes in pass 2
354msTotal layout phase time: 6ms

Any thoughts ?


To me it looks you just have too much staff you try to squeeze into 100% height layout and the rest will be clipped. Removing the .expand(list) part of your code make the layout use the space it needs (and scrollbar will appear).


Yep, You’re right.

I’ll let u know when completed the fix.