Setup Mondrian on Mac OSX

Posted by & filed under Code, Java, Work.

The Mondrian documentation is terrible, and Java isn’t something you get to easily “dabble” in.  My goal was to setup Mondrian on my Mac OSX machine, starting with Mondrian 3.5.  While trying to set up the initial FoodMart sample dataset I ran into a bunch of java errors, always something like

Exception in thread "main" java.lang.NoClassDefFoundError: mondrian/test/loader/MondrianFoodMartLoader
Caused by: java.lang.ClassNotFoundException: mondrian.test.loader.MondrianFoodMartLoader
 at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

Based on various forum posts and other blog posts, I found this to be the most direct route to get it installed. This is all assuming you have your JDK up to date…

  1. Install Tomcat 7
  2. Download Mondrian (3.5.0 – I didn’t see the starter .sql script in the /demo folder, so I opted for 3.4.1 at first)
  3. DEPLOY THE MONDRIAN WEBAPP.  Once Tomcat is up, copy from the mondrian download /lib/mondrian.war to the “webapps” directory for tomcat.  If you follow the steps in the Tomcat install I linked to, this will be /Library/Tomcat/webapps.  This will unpack the app into /Library/Tomcat/webapps/mondrian

You should now be ready to run the java command to build your sample dataset as in: http://mondrian.pentaho.com/documentation/installation.php#MySQL_on_Linux_example

The sample command usually looks like:

$ java -cp "/mondrian/lib/mondrian.jar:/mondrian/lib/log4j.jar:/mondrian/lib/commons-logging.jar:/mondrian/lib/eigenbase-xom.jar:/mondrian/lib/eigenbase-resgen.jar:/mondrian/lib/eigenbase-properties.jar:/usr/local/mysql/mysql-connector-java-5.0.5-bin.jar"
     mondrian.test.loader.MondrianFoodMartLoader
     -verbose -tables -data -indexes
     -jdbcDrivers=com.mysql.jdbc.Driver
     -inputFile=/mondrian/demo/FoodMartCreateData.sql
     -outputJdbcURL="jdbc:mysql://localhost/foodmart?user=foodmart&password=foodmart"

Horrific example since it doesn’t talk about where you should be running this from, or where any of these .jar files should be…  Since you’ve deployed the web-app, we can make our lives easier by including the /lib directory of the web app in the classpath.  NOTE: you may need to manually download your jdbc database driver, sticking it in the Tomcat /lib for your mondrian web-app keeps things simple.   Also – note the “inputFile” parameter, this should be set to the location of the “FoodMartCreateData.sql” script, usually in the “demo” folder in the Mondrian download.  Just pay attention to where the file is or where you run the script from and you should be fine.

$ java -cp "/Library/Tomcat/webapps/mondrian/WEB-INF/lib/*"
     mondrian.test.loader.MondrianFoodMartLoader
     -verbose -tables -data -indexes
     -jdbcDrivers=com.mysql.jdbc.Driver
     -inputFile=mondrian/demo/FoodMartCreateData.sql
     -outputJdbcURL="jdbc:mysql://localhost/foodmart?user=foodmart&password=foodmart"

After this I follwed the rest of the setup instructions (modifiation of the web.xml file and a few of the .jsp pages), and I was able to pivot away in the browser…

Tags:

2 Responses to “Setup Mondrian on Mac OSX”

  1. Luc Boudreau

    Hello Garrett, sorry you ran into these issues. Here are a few quick tips which I’m sure you’ll wish you had known beforehand.

    Here’s how to get started wiht Mondrian in a jiffy.

    1. Clone our Git repository (or fork & clone)

    git clone https://github.com/pentaho/mondrian.git

    2. Create a file at the root of the project. Call it ‘mondrian.properties’ and add this. Tweak it as needed. It doens’t have to be MySQL.

    mondrian.foodmart.jdbcURL=jdbc:mysql://localhost/foodmart
    mondrian.foodmart.jdbcUser=foodmart
    mondrian.foodmart.jdbcPassword=foodmart
    mondrian.jdbcDrivers=com.mysql.jdbc.Driver
    driver.classpath=/Users/foo/mysql-connector-java.jar

    3. Compile it. If you run into issues about JAVA_HOME, pop open buildOnJdk.sh and look for a section where you can add your own paths.

    ant jar

    4. Load the demo database. It’ll use the properties you have defined above. You could also use the low level loader classes, but you don’t really have to.

    ant load-foodmart

    5. Make your changes and run some tests.

    ant junit-main

    For all the finicky details read these.

    Git workflow:
    https://github.com/pentaho/mondrian/wiki/Forking-and-Contributing-to-Mondrian

    Dev guide:
    http://mondrian.pentaho.com/documentation/developers_guide.php

    Reply

Leave a Reply