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
Jun 08

How to install zeromq (0MQ) in Ubuntu with Java bindings

I tested this in Ubuntu 13.04, but essentially this should work in any Ubuntu distribution. First install the libtool, autoconf, automake, uuid-dev, e2fsprogs packages.

sudo apt-get install libtool autoconf automake uuid-dev e2fsprogs

Then clone the 0mq source using,

git clone git://github.com/zeromq/libzmq.git

Then go in to the libzmq directory and run the following commands in order.

./autogen.sh
./configure
make
sudo make install
ldconfig -v

Then run the following command and check the output.

ls -al /usr/local/lib/libzmq.*

The output should be similar to,

-rw-r--r-- 1 root root 7082022 ජූනි 7 14:16 /usr/local/lib/libzmq.a
-rwxr-xr-x 1 root root 947 ජූනි 7 14:16 /usr/local/lib/libzmq.la
lrwxrwxrwx 1 root root 15 ජූනි 7 14:16 /usr/local/lib/libzmq.so -> libzmq.so.3.0.0
lrwxrwxrwx 1 root root 15 ජූනි 7 14:16 /usr/local/lib/libzmq.so.3 -> libzmq.so.3.0.0
-rwxr-xr-x 1 root root 2876918 ජූනි 7 14:16 /usr/local/lib/libzmq.so.3.0.0

Now you should install the Java bindings for 0mq (in order to use omq from Java of course!). First check whether the JAVA_HOME environment variable is correctly set using,

echo $JAVA_HOME

This should output the location that you have installed Java. If it’s giving an empty output, then set it manually using

export JAVA_HOME=/location/to/your/java/installation

In my case the command is,

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_17

Then clone the java bindings for 0mq using,

git clone https://github.com/zeromq/jzmq.git

now go inside the jzmq folder. Now same as before, run the following commands in order.

./autogen.sh
./configure
make
sudo make install

Now run the following command to verify the installation.

ls -al /usr/local/lib/*jzmq* /usr/local/share/java/*zmq*

The output should be like the following.

-rw-r--r-- 1 root root 535266 ජූනි 7 14:40 /usr/local/lib/libjzmq.a
-rwxr-xr-x 1 root root 998 ජූනි 7 14:40 /usr/local/lib/libjzmq.la
lrwxrwxrwx 1 root root 16 ජූනි 7 14:40 /usr/local/lib/libjzmq.so -> libjzmq.so.0.0.0
lrwxrwxrwx 1 root root 16 ජූනි 7 14:40 /usr/local/lib/libjzmq.so.0 -> libjzmq.so.0.0.0
-rwxr-xr-x 1 root root 242784 ජූනි 7 14:40 /usr/local/lib/libjzmq.so.0.0.0
-rw-r--r-- 1 root root 40618 ජූනි 7 14:40 /usr/local/share/java/zmq.jar

Notice the last line, that’s the newly created jar that connects to 0mq. Now you can use 0mq inside a Java programme.

Troubleshooting

If you get any of the following errors (which I got) when building the jar, export the mentioned system variables in the terminal to resolve them.

error

checking for javah… no

configure: error: cannot find javah

solution

export JAVAH=/location/to/your/java/installation/bin/javah

ex – export JAVAH=/usr/lib/jvm/jdk1.7.0_17/bin/javah

error

checking for jar… no

configure: error: cannot find jar

solution

export JAR=/location/to/your/java/installation/bin/jar

ex – export JAR=/usr/lib/jvm/jdk1.7.0_17/bin/jar

(Most of the content of this guide is based up on https://github.com/mslinn/zeromq-demo#ubuntu )

Share Button
Oct 09

My presentation on the internship at WSO2

This is the presentation I did after completing 5 months of internship in WSO2.  

Share Button