Oct 07

Using dCharts in Vaadin 7

I wanted a decent charting library to use in one of my FOSS projects which was created using Vaadin 7.1.2. Since Vaadin charts, the default choice for that purpose under Vaadin 7 needs a license to use it, I  switched my attention towards dCharts (https://vaadin.com/directory#addon/dcharts-widget). So I added the following maven dependency which is listed in the Vaadin site to my project and built it.

<dependency>
    <groupId>org.vaadin.addons</groupId>
    <artifactId>dcharts-widget</artifactId>
    <version>1.7.0</version>
</dependency>

But when I ran the project in the application server, I got the following error.

12:27:18,947 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) Class Path entry vaadin-server-7.0.7.jar in "/content/ui-0.1.war/WEB-INF/lib/dcharts-widget-1.7.0.jar" does not point to a valid jar for a Class-Path reference.
 12:27:18,951 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) Class Path entry vaadin-shared-7.0.7.jar in "/content/ui-0.1.war/WEB-INF/lib/dcharts-widget-1.7.0.jar" does not point to a valid jar for a Class-Path reference.
 12:27:18,957 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) Class Path entry vaadin-theme-compiler-7.0.7.jar in "/content/ui-0.1.war/WEB-INF/lib/dcharts-widget-1.7.0.jar" does not point to a valid jar for a Class-Path reference.
 12:27:18,961 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) Class Path entry vaadin-client-compiled-7.0.7.jar in "/content/ui-0.1.war/WEB-INF/lib/dcharts-widget-1.7.0.jar" does not point to a valid jar for a Class-Path reference.
 12:27:18,963 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) Class Path entry vaadin-themes-7.0.7.jar in "/content/ui-0.1.war/WEB-INF/lib/dcharts-widget-1.7.0.jar" does not point to a valid jar for a Class-Path reference.
 12:27:18,965 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) Class Path entry commons-lang3-3.1.jar in "/content/ui-0.1.war/WEB-INF/lib/dcharts-widget-1.7.0.jar" does not point to a valid jar for a Class-Path reference.
 12:27:18,966 WARN [org.jboss.as.server.deployment] (MSC service thread 1-6) Class Path entry commons-codec-1.7.jar in "/content/ui-0.1.war/WEB-INF/lib/dcharts-widget-1.7.0.jar" does not point to a valid jar for a Class-Path reference.

Looking at the error, it was evident that dCharts was looking at the wrong set of jars. So here’s what I did to overcome this problem.

First of all, checkout the dCharts code from http://source.dussan.org/dcharts . Then change the com.vaadin.vaadin value in the pom to 7.1.2 . Then rebuild the dCharts projects (mvn clean install).

Now open your Vaadin project. Go to the place in the pom where you added your dCharts dependency and replace it with the following.

<dependency>
    <groupId>org.dussan.vaadin</groupId>
    <artifactId>dcharts</artifactId>
    <version>1.7.0</version>
</dependency>

Now rebuild your Vaadin project (mvn clean install). Everything should work fine!.

p.s

Don’t forget to add your chart to the UI using addComponent() method to make the chart visible!.

Share Button