Sunday, January 3, 2010

Playing around with Apache Camel on Ubuntu, Part 1: Setup

OS: Ubuntu 9.10

On the Developer's Building Page, it states that Java 1.5 is a requirement for building Apache Camel. The J2SE 5.0 reached its End of Service Life Nov. 3rd, 2009, but the required file can be found as the JDK 5.0 with Java EE on Sun's Java SE Downloads - Previous Release - J2SE 5.0 page.

I downloaded and put the java_ee_sdk-5_01-linux.bin file near my camel source code, but I didn't know exactly what I was supposed to do with it (since I have java 6 installed) until I tried to do a mvn install in the camel directory. When I tried to do a build, I got a message like this from maven:

Missing:
1) com.sun:tools:jar:1.5.0
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.5.0 -Dpackaging=jar -Dfile=/path/to/file

I ran that command using the path to the java_ee_sdk-5_01-linux.bin file, and it seemed to build fine. It also put a tools-1.5.0.jar file in /root/.m2/repository/com/sun/tools/1.5.0/.

I thought that, having installed the jar file there, maven would know where to find it next time around. However, it didn't work that way. The next time I did mvn install, I got the same missing message:

Missing:
1) com.sun:tools:jar:1.5.0
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.5.0 -Dpackaging=jar -Dfile=/path/to/file

I started trying to play around with the pom.xml files as described here, and got it to partially build, but then it started complaining about the maven plugin pom.xml files ....

Long story short, that jar file had to be renamed and placed in my ${java.home}/.../lib directory with the name "tools.jar". However, ${java.home} does not refer to the $JAVA_HOME environment variable. It refers to your installation directory, which apparently cannot be set as an environment variable (forgive my ignorance on such topics). In order to set it to the right installation directory (sun's - it won't work if you put it in the openjdk directory), I had to run:

sudo update-alternatives --config java

Which brings up something like the following:

There are 4 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/bin/gij-4.3 43 manual mode
2 /usr/bin/gij-4.4 1044 manual mode
3 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
* 4 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode

Press enter to keep the current choice[*], or type selection number:

For me, 0 was initially selected. I selected 4, and placed copied the tools-1.5.0.jar from the
/root/.m2/repository/com/sun/tools/1.5.0/ directory and placed it as tools.jar inside of /usr/lib/jvm/java-6-sun/jre/lib/

This time it built. It is now running all the tests, because I was silly and didn't tell it not to (mvn -Dtest=false -DfailIfNoTests=false clean install).

Update: It will report BUILD FAILURE if any of the tests fail, even if the build itself was successful.

Update #2: Turns out I am just inept and didn't make sure I was using sun's java. Builds pretty well when using sun's java.

No comments:

Post a Comment