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…
- Install Tomcat 7
- 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)
- 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…