Mondrian doesn't ship with a WAR file by default anymore. This inhibits people from trying out Mondrian via its XML/A servlet.

What is Mondrian?

Mondrian is like a database driver for MDX (OLAP) queries. OLAP is an analytical pattern for designing data warehouses and data-marts. MDX is an SQL like query syntax for getting information from OLAP designed datasources. MDX was invented by Microsoft and is somewhat standardized by the wider community.

So, Mondrian basically translates MDX queries into any number of SQL queries and aggregates the results. Now, Mondrian is basically a Java library, so you get the results as Java objects. The XML/A servlet as a part of the Mondrian project returns the results to you via SOAP. XML/A is a standard to structure MDX/OLAP interactions with SOAP.

The xmondrian Project

Roland Bouman started the xmondrian project on Github https://github.com/rpbouman/xmondrian, a WAR file built with mondrian plus some other OLAP and XML/A projects. But, the project doesn't have any sources for the build process. Since this project is a bit old, and only has 1 binary release, it's not up-to-date anymore. I wanted to re-invent this project and deliver a stock mondrian WAR file and a WAR file bundled with all the extras included in xmondrian.

My new project is at: https://github.com/markkimsal/mondrian.war

Building on Top of Docker

Using docker quickly gets me a Java environment. Automating the installation of a JDK is quite troublesome because of the license that you have to accept to download directly from Oracle (nee Sun).

FROM maven:3.5-jdk-8-alpine
RUN apk update && apk add git

VOLUME ["/app", "/war-skeleton", "/xwar-skeleton", "/maven"]

ENTRYPOINT ["/bin/sh"]

This just pulls down a maven docker image and exposes 4 directories that we can attach to our local drive with volumes.

The war-skeleton and xwar-skeleton give you the files and directory structure to configure your own war file and add in whatever you want. Currently, it only adds xmla4js to the root of the WAR. xmla4js is another project by Roland Bouman which handles all the SOAP and AJAX interaction with Mondrian's XML/A servet. (it doesn't create MDX for you).

Building the WAR

docker build -t markkimsal/mondrian-war-build:latest .
sh ./build-with-docker.sh xmondrian

First, download the maven alpine image and expose the 4 volumes and tag it so you can refer to it without the randmon hash. Next, run the build-with-docker.sh file to run the new image with all the connected volumes. You can pass the flag xmondrian or not to get the additional projects in your war.

The resulting WAR file will have a web.xml that exposes the XML/A servlet at the path /xmla.

Not all of the xmla4js sample pages work because some of them are hardcoded to hit /xmondrian/xmla as a path. You can configure your web.xml to expose the WAR at any path, or you can simply rename the war file before deploying it to Jetty.

Building with Maven

The heart of Mondrian's build process is maven and the parent-poms. You have to checkout the maven-parent-poms project and then checkout mondrian under pentaho-ce-jar-parent-pom/pentaho-ce-jar-parent-pom. From there, mvn -DrunITs install.

Deplying the WAR to Jetty

Simply move the resulting mondrian.war or xmondrian.war to your Jetty's webapps/ directory and run java -jar start.jar.

3 Files to Configure Mondrian + Jetty

In theory, you can do this in with 2 files, but I didn't get it to work. First, you need to tell Jetty to "override" the web.xml that is compiled into the WAR file. (It doesn't seem to override the file, but rather merge the contents).

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="war">webapps/xmondrian.war</Set>
    <Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>/mondrian-web.xml</Set>
</Configure>

This allows you to put your own web.xml right in the jetty root (or maybe you should put it under etc/) - but not in the webapps folder.

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1" metadata-complete="true">
  <display-name>xmondrian</display-name>
  <description>
     Mondrian XML/A servlet, sample schemas and datasets, and client libraries and tools.
  </description>
  <servlet>
    <servlet-name>MondrianXmlaServlet</servlet-name>
    <description>
      MondrianXmlaServlet.
      Provides a XML/A (XML for Analysis) interface to the Mondrian (R)OLAP engine.
    </description>
    <!--
      These are other classes that implement a XML/A provider servelt on top of Mondrian.
      <servlet-class>mondrian.xmla.impl.Olap4jXmlaServlet</servlet-class>
      <servlet-class>mondrian.xmla.impl.MondrianXmlaServlet</servlet-class>
    -->
    <servlet-class>mondrian.xmla.impl.DynamicDatasourceXmlaServlet</servlet-class>

    <!--
    <init-param>
      <param-name>CharacterEncoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    -->

    <!--
    This parameter is commented out intentionally;
    this way, mondrian will assume the default location for the data source configuration
    The default location is WEB-INF/datasources.xml
    -->
    <init-param>
      <param-name>DataSourcesConfig</param-name>
	  <param-value>file:///absolute/path/to/your/jetty-distribution-9.4.8.v20171121/datasources.xml</param-value>
    </init-param>

    <!--
    <init-param>
      <param-name>requireAuthenticatedSessions</param-name>
      <param-value>false</param-value>
    </init-param>
    -->
  </servlet>

  <servlet-mapping>
    <servlet-name>MondrianXmlaServlet</servlet-name>
    <url-pattern>/xmla</url-pattern>
  </servlet-mapping>
</web-app>

Now you can specify your datasources. Make sure you put your mysql-connector-java-5.1.39.jar into lib/ext/ of Jetty.

<?xml version="1.0"?>
<!--
  http://mondrian.pentaho.com/documentation/installation.php#5_1_Describe_the_data_sources_in_datasources.xml
-->
<DataSources>
  <DataSource>
    <DataSourceName>Foodmart</DataSourceName>
    <DataSourceDescription>Foodmart Sample Data</DataSourceDescription>
    <URL>http://localhost:8080/xmondrian/xmla</URL>
	<!--
    <DataSourceInfo>Provider=mondrian;Jdbc=jdbc:hsqldb:res:/hsqldb-foodmart/foodmart;JdbcDrivers=org.hsqldb.jdbc.JDBCDriver</DataSourceInfo>
	-->
	<DataSourceInfo>Provider=mondrian;  JdbcUser=docker; JdbcPassword=mysql; Jdbc=jdbc:mysql://127.0.0.1/my_data_warehouse;JdbcDrivers=com.mysql.jdbc.Driver</DataSourceInfo>
    <ProviderName>Mondrian</ProviderName>
    <ProviderType>MDP</ProviderType>
    <AuthenticationMode>Unauthenticated</AuthenticationMode>
    <Catalogs>
        <Catalog name="FoodMart">
            <Definition>/WEB-INF/schema/FoodMart.xml</Definition>
        </Catalog>
    </Catalogs>
  </DataSource>
</DataSources>

The Projects

Mondrian WAR project is at: https://github.com/markkimsal/mondrian.war

xmla4js: https://github.com/rpbouman/xmla4js

xavier (Web GUI charts): https://github.com/rpbouman/xavier

outdated xmondrian: https://github.com/rpbouman/xmondrian

Pentaho Parent POMs: https://github.com/pentaho/maven-parent-poms