Sakai with Java 6 and Tomcat 6

Building and deploying Sakai with Java 6 and Tomcat 6 has been on my list of things to do for a while. I finally got around to it and here’s my findings.

First, how to switch Java versions on a Mac

You’ll need a 64bit Mac running OS 10.5 (Leopard) and should have recently run Software Update to get it automatically installed.

Open Applications > Utilities > Java > Java Preferences and in Java application versions drag Java SE 6 to the top. Assuming your JAVA_HOME environment variable points to /Library/Java/Home then that is all you need to do. To confirm, open Terminal and type:

java -version

You should get something similar to the following:

java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)

Building Sakai with Java 6 and Tomcat 5.5
You don’t need to do anything special to build Sakai with Java 6. Maven uses the JAVA_HOME property, and this now points to your Java 6 installation. Since you are still using Tomcat 5.5, nothing changed there either.

For more accurate results I first deleted my ~/.m2/org/sakaiproject/ directory to clear it of the artifacts built against Java 5.

Build command:

mvn clean install sakai:deploy


Sakai version build deploy startup testing*
cafe-2.5.x success success success success
2.6.x success success success success

Building Sakai with Java 6 and Tomcat 6
The structure of Tomcat 6 has changed since Tomcat 5.5. The common, shared and server directories are flattened into a single directory ‘lib’. So all jars need to be deployed into that location.

To deploy to Tomcat 6 you need an additional flag for Maven:

Build command:

mvn clean install sakai:deploy

Sakai version build deploy startup testing*
cafe-2.5.x success partial success success
2.6.x success partial success success

The partial results in the deploy were that most jars were deployed into lib only, except some were still deployed to common/lib and shared/lib. Starting up Tomcat with these left in those locations caused failures on every webapp.

In this image you can see the artifacts that were deployed to common/lib and shared/lib. I moved them into lib manually and Tomcat started normally.

Watching the logs I found one common stacktrace:

caused by: java.lang.NoClassDefFoundError: org/apache/commons/el/Logger

I went searching and noticed that no commons-el.jar was available anywhere (which contains the missing class). I compared this to my Tomcat 5.5 deployment and it was in common/lib. I added this to the Tomcat6 lib/ and restarted. Success! Once the classes were all moved into lib/ and the missing jar added, everything seemed to worked fine*. I’d really like to get some feedback on other people’s experiences regarding this so post some comments.

Disclaimer: testing* consisted of verifying the portal works, creating an account, logging in, uploading some resources, filling out my profile, creating a site, editing the wiki, posting a chat message and just general navigating around. It was by no means exhaustive!

3 thoughts on “Sakai with Java 6 and Tomcat 6

  1. I encountered an issue with the Java Despite moving Java SE 6 to the top of the preferences pane and then starting my terminal in order to check which Java version was running, the never updated the running version of Java.
    I fixed this problem by doing the following:
    cd /System/Library/Frameworks/JavaVM.framework/Versions
    sudo mv CurrentJDK CurrentJDK.orig

    After that the Java worked as expected:

    arwhyte$ java -version
    java version “1.6.0_17″Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)

  2. I noticed this as well, but thought it was just my machine.I’ve since upgraded to Snow Leopard so don’t even get the option to change it in the Pref Pane any more, even though the older JDKs are still there on the file system (yes I can still see you!)

    Thanks for the tip!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s