Introduction

Mondrian is a very popular open source OLAP Server and is also one of the products that are very oftenly asked in several discussion forums. One of those including installation and initial configuration issues.

In this article I will try to guide step by step on how to get Mondrian installed and configured using MySQL community database server and Windows XP as its operating system platform.

Prerequisites

    These are the applications that are needed before you can using Mondrian, follow on the link for more information on how to setup each application :

    MySQL Foodmart Database Sample

    Mondrian provided Foodmart database sample in MS Access format. But I have provided a full generated MySQL script populate Foodmart so you use it in MySQL Community database server. You can download the tar.gz compressed file from my wiki site (picture).

    Extract the script file using your favorite compression utility - 7zip is the one I would highly recommend.

    Create a database and execute the script. Below is a sample commands to create a Foodmart database - assuming that your mysql is running and your mysql.exe client is located in C:\mysql\bin with your previously extracted script file in C:\foodmart_mysql.sql.

    Open command line prompt (Start | Run | type cmd | click OK)


    C:\mysql\bin\mysql.exe -Uroot -e "create database Foodmart"

    C:\mysql\bin\mysql.exe -Uroot Foodmart < C:\foodmart_mysql.sql

    C:\mysql\bin\mysql.exe -Uroot Foodmart -e "show tables"


    You should see result like below if all running well...



    +-------------------------------+
    | Tables_in_foodmart_mondrian |
    +-------------------------------+
    | account |
    | agg_c_10_sales_fact_1997 |
    | agg_c_14_sales_fact_1997 |
    | agg_c_special_sales_fact_1997 |
    | agg_g_ms_pcat_sales_fact_1997 |
    | agg_l_03_sales_fact_1997 |
    | agg_l_04_sales_fact_1997 |
    | agg_l_05_sales_fact_1997 |
    | agg_lc_06_sales_fact_1997 |
    | agg_lc_100_sales_fact_1997 |
    | agg_ll_01_sales_fact_1997 |
    | agg_pl_01_sales_fact_1997 |
    | category |
    | currency |
    | customer |
    | days |
    | department |
    | employee |
    | employee_closure |
    | expense_fact |
    | inventory_fact_1997 |
    | inventory_fact_1998 |
    | position |
    | product |
    | product_class |
    | promotion |
    | region |
    | reserve_employee |
    | salary |
    | sales_fact_1997 |
    | sales_fact_1998 |
    | sales_fact_dec_1998 |
    | store |
    | store_ragged |
    | time_by_day |
    | warehouse |
    | warehouse_class |
    +-------------------------------+


    Configuring and Running Tomcat

    You will need to copy mysql driver, i.e. mysql-connector-java-5.1.6-bin.jar file to your Tomcat's library folder.
    • Extract your MySQL zipped driver file you have downloaded before to get the jar file
    • Copy the jar driver to C:\apache-tomcat-5.5.17\common\lib folder - which is the location for any jar drivers used in our web application. For version 6 of tomcat you just put it in APACHE_TOMCAT/lib folder
    Run your server by typing "catalina run" in Tomcat's bin folder.

    cd c:\apache-tomcat-5.5.17\bin
    catalina run

    Check your running server by browsing into http://localhost:8080. If everything works fine, our next step is to deploy Mondrian web application.

    Deploying Mondrian


    Extract mondrian distribution package and goto lib directory. You will find mondrian.war file there.

    Copy the war file into your Tomcat's webapps directory while Tomcat is still running. The war file will be extracted and deployed into Tomcat automatically.



    Browse into your http://localhost:8080/mondrian and you shall get a Mondrian welcome page like below.



    Configure JSP File

    Browse into Mondrian's application queries folder where you can find several sample jsp files. Here I open my C:\apache-tomcat-5.5.17\webapps\mondrian\WEB-INF\queries folder and find the following jsp files :
    • fourheir.jsp
    • mondrian.jsp
    • colors.jsp
    • arrows.jsp

    Edit those files using your favorite editor, and change following line :



    ..... this is your existing mdx query ....



    into your MySQL database configuration. For example ...




    ..... this is your existing mdx query ....



    Browse Your Multi Dimensional Data

    Now you are ready to browse multidimensional data with JPivot. Browse into your local mondrian address : http://localhost:8080/mondrian, choose the first mondrian examples "JPivot pivot table".

    This will show a view of multidimensional query but It will take some time as Mondrian will need to populate its initial cache.

    After that, you will see a table with multidimensional which you can drill in hierarchical way and a heading toolbar which comprises of configuration icons.


    Congratulations, your Mondrian with MySQL database has been successfully setup !


    10 comments:

    Antoine said...

    Thanks for the blog. I am struggling identifying:
    mysql-connector-java-6.0.16-bin.jar

    Where can I find the file?
    Can I user mysql-connector-java-5.1.3-rc-bin.jar
    and rename it to mysql-connector-java-6.0.16-bin.jar instead?

    How can I know it is correctly set up?

    Feris Thia said...

    Hi Antoine,

    Thanks for the commment.

    You can put your jar file in server wide library folder or in your web app library folder.

    For example in server wide you can put it in :

    [TOMCAT SETUP]\lib

    Replace [TOMCAT SETUP] with your own Apache Tomcat's directory.

    And to test your setup, I have write a wiki article with a sample jsp file. Visit the article here (http://sites.google.com/a/dlpage.phi-integration.com/pentaho/mondrian/check-mysql-setup).


    Feris Thia

    Pablo said...

    Hi, after doing all that, i'm getting this:

    JPivot had an error ...

    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: Mondrian Error:Syntax error at line 2, column 2, token 'EOF'

    Any ideas?

    Feris Thia said...

    Hi Pablo,

    Yes, it seems that you have remove your mdx query in jp:mondrianQuery tag. Well, it is a mistake in my instructions.. I have updated this. Very sorry for that.

    Add mdx query in these following jsp files - inside of jp:mondrianQuery tag :
    ----------------------------------
    - mondrian.jsp
    select
    {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].[Store Sales]} on columns,
    {([Promotion Media].[All Media], [Product].[All Products])} ON rows
    from Sales
    where ([Time].[1997])
    ----------------------------------
    - fourhier.jsp

    select {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].[Store Sales]} on columns,
    {([Gender].[All Gender], [Marital Status].[All Marital Status],
    [Customers].[All Customers],
    [Product].[All Products] ) } on rows
    from Sales where ([Time].[1997])
    ----------------------------------
    - colors.jsp

    with member [Measures].[ROI] as '(([Measures].[Store Sales] - [Measures].[Store Cost]) / [Measures].[Store Cost])', format_string = IIf((((([Measures].[Store Sales] - [Measures].[Store Cost]) / [Measures].[Store Cost]) * 100.0) > 150.0), "|#.00%|style='green'", IIf((((([Measures].[Store Sales] - [Measures].[Store Cost]) / [Measures].[Store Cost]) * 100.0) < 150.0), "|#.00%|style='red'", "#.00%"))
    select {[Measures].[ROI], [Measures].[Store Cost], [Measures].[Store Sales]} ON columns,
    {[Product].[All Products]} ON rows
    from [Sales]
    where [Time].[1997]
    ----------------------------------
    - arrows.jsp

    with member [Measures].[ROI] as '(([Measures].[Store Sales] - [Measures].[Store Cost]) / [Measures].[Store Cost])', format_string = IIf((((([Measures].[Store Sales] - [Measures].[Store Cost]) / [Measures].[Store Cost]) * 100.0) > 150.0), "|#.00%|arrow='up'", IIf((((([Measures].[Store Sales] - [Measures].[Store Cost]) / [Measures].[Store Cost]) * 100.0) < 150.0), "|#.00%|arrow='down'", "|#.00%|arrow='none'"))
    select {[Measures].[ROI], [Measures].[Store Cost], [Measures].[Store Sales]} ON columns,
    {[Product].[All Products]} ON rows
    from [Sales]
    where [Time].[1997]

    ----------------------------------

    You can visit this page for more description on this tag.

    Feris Thia

    Orso pigro said...

    Hi, thanks for the blog.
    But, after doing all that, i'm getting this:

    JPivot had an error ...

    org.apache.jasper.JasperException: Exception in JSP: /testpage.jsp:44

    at org.apache.jasper.servlet.JspServletWrapper.
    handleJspException(JspServletWrapper.java:451) ...
    at java.lang.Thread.run(Unknown Source)

    Any ideas?

    Feris Thia said...

    Hi Orso,

    Can you be more detail ?

    Have you setup and running your MySQL correctly ? Have you load the sample data ? Have you copied the jdbc jar to Tomcat's library folder ? Have you configured the jsp ?

    Thanks,

    Feris

    sergiom said...

    This is a very good tutorial! Thank you very much for allowing me to set up a working Mondrian instance in 15 minutes!

    Fyi: I encountered some problems when editing .jsp files.

    I had to replace tag names (mondrianquery with mondrianQuery, jdbcurl with jdbcUrl, .. etc, ...) and all worked fine.

    Thank you again.

    achmul said...

    hi feris, i have error like this :

    JPivot had an error ...

    org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: com.tonbeller.jpivot.olap.model.OlapException: Mondrian Error:Syntax error at line 6, column 2, token '<'

    anu ideas ?

    thank's

    Anonymous said...

    Hi feris
    thanks for the blog, it's a very good tutorial

    all my system work fine (MySQL, Tomcat, mondrian foodmart ex) all tests run but only the second test "Jpivot jpivot table by XMLA " responds

    JPivot had an error ...

    org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: com.tonbeller.jpivot.olap.model.OlapException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:

    I work with
    Tomcat 6.0.18
    java 1.5.0_15
    mysql 5.0.51a
    mysql-connector 5.1.6
    mondrian 3.0.4

    Anonymous said...

    About the topic 'JPivot had an error ...' I had the same problem I have solved deleting the file xalan.jar from the lib directory