Skip to main content

How to successfully compile the Mongobird source code

In May I published this post (http://googlielmo.blogspot.ie/2014/05/open-source-projects-and-documentation.html) talking about a couple of bad habits I often find in Opens Source projects, in particular out-of-date build files. A couple of days ago I have downloaded from GitHub the latest source codes of the Mongobird (https://github.com/citsoft/mongobird), a tool providing a dashboard to monitor MongoDB databases in order to evaluate the non-commercial version and I tried to build it through Maven (the Mongobird project is a Maven Java project). Trying to compile first using the mvn compile command gave a lot of errors. I think at least compilation should work downloading a project from a public repository or have some documentation associated to the source code in order to guide the users to quickly have the tool built and running. Unfortunately none of those applies to the Mongobird project source code. In this post I am describing the steps to successfully compile it and make it working starting from the source code in order to help other people who should download this project to save their time.
Before starting, the details about the environment I am using:
  • IBM JDK 1.6 (but everything in this process works fine with the Oracle JDK as well)
  • Maven 3.1.1
  • Jetty 8.1.13
  • MongoDB 2.6.4
  • Mongobird 2.5.0 source code
A couple of dependencies should be manually added to the local Maven repository (not available in any public repository):

mvn install:install-file -DgroupId=net.cit.monad-Mongo -DartifactId=monad-Mongo -Dpackaging=jar -Dversion=0.0.1-SNAPSHOT -Dfile=monad-Mongo-0.0.1-20121219.074054-3.jar -DgeneratePom=true

and

mvn install:install-file -DgroupId=net.citsoft -DartifactId=distr-communication -Dpackaging=jar -Dversion=1.0.0 -Dfile=distr-communication-1.0.0.jar -DgeneratePom=true

monad-Mongo-0.0.1-20121219.074054-3.jar could be find in the lib folder of the project.
distr-communication-1.0.0.jar can be taken from the installation package of Mongobird downloadable from the Mongobird official website (http://mongobird.citsoft.net/?page_id=456).
Then replace the content of the POM file of the project with the following:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.cit.tetrad</groupId>
    <artifactId>tetrad</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Tetrad Maven Webapp</name>

    <build>
        <finalName>tetrad</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <filters>
            <filter>${tetradConfigFile}</filter>
        </filters>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <junitArtifactName>junit:junit</junitArtifactName>
                    <systemProperties>
                        <property>
                            <name>java.awt.headless</name>
                            <value>true</value>
                        </property>
                    </systemProperties>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <webResources>
                        <resource>
<!--                             this is relative to the pom.xml directory -->
                            <directory>src/main/java/net/cit/tetrad/template</directory>
                            <targetPath>WEB-INF/classes/net/cit/tetrad/template</targetPath>
                            <includes>
                                <include>**</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
   
    <properties>
        <spring.version>3.1.0.RELEASE</spring.version>
        <junit.version>3.8.1</junit.version>
        <log4j.version>1.2.16</log4j.version>
        <slf.version>1.6.4</slf.version>
        <jstl.version>1.2</jstl.version>
    </properties>
   
    <dependencies>
<!--         <dependency>      -->
<!--               <groupId>javax.servlet</groupId>      -->
<!--               <artifactId>servlet-api</artifactId>      -->
<!--               <version>2.5</version> -->
<!--           </dependency> -->
<!--           <dependency>      -->
<!--               <groupId>javax.servlet</groupId>      -->
<!--               <artifactId>jsp-api</artifactId>      -->
<!--               <version>2.0</version>      -->
<!--           </dependency> -->
        <dependency>    
              <groupId>javax.servlet</groupId>    
              <artifactId>servlet-api</artifactId>    
              <version>2.4</version>    
              <scope>provided</scope>  
          </dependency>
        <dependency>
            <groupId>net.cit.monad-Mongo</groupId>
            <artifactId>monad-Mongo</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework.data</groupId>
          <artifactId>spring-data-commons-core</artifactId>
          <version>1.2.0.M2</version>
          <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-tx</artifactId>
                </exclusion>
          </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>           
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-core</artifactId>
            <version>5.4.2</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>net.disy.jquery</groupId>
            <artifactId>jquery</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>net.disy.jquery</groupId>
            <artifactId>jquery-ui</artifactId>
            <version>1.8.6</version>
        </dependency>
        <dependency>
      <groupId>org.rrd4j</groupId>
      <artifactId>rrd4j</artifactId>
      <version>2.1.1</version>
    </dependency>
        <dependency>
            <groupId>net.sf.ezmorph</groupId>
            <artifactId>ezmorph</artifactId>
            <version>1.0.6</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>       
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
<!--             <version>1.8.6</version> -->
            <version>2.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.3</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.7</version>
        </dependency>
        <dependency>
            <groupId>net.citsoft</groupId>
            <artifactId>distr-communication</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>2.12.2</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.7.3</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.7.3</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk16</artifactId>
            <version>1.46</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>
    </dependencies>
   
    <profiles>
        <profile>
            <id>tetradBuild</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <file>
                    <exists>${configPath}/tetrad-config.prop</exists>
                </file>
            </activation>
            <properties>
                <tetradConfigFile>${configPath}/tetrad-config.prop</tetradConfigFile>
            </properties>
        </profile>
        <profile>
            <id>tetradDefault</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <missing>${configPath}/tetrad-config.prop</missing>
                </file>
            </activation>
            <properties>
                <tetradConfigFile>${basedir}/config/tetrad-config-default.prop</tetradConfigFile>
            </properties>
        </profile>
    </profiles>
   
</project>


I got most part of the missing dependencies and their release numbers form the pom.xml file embedded in the monad-Mongo-0.0.1-20121219.074054-3.jar library. Other dependencies were discovered checking the exceptions at runtime testing the single features of this software.
Before packaging the final WAR you need to change the connection to MongoDB timeout value. Open the tetrad-config-default.prop file you can find in the config folder of the project using any text editor and change the value for the mongo.connectTimeout property from 0 to any value greater than 0 (in milliseconds). For example:

mongo.connectTimeout:10000

Even if 0 means infinite time for this property, if you let this default value after the application start and the connection to the MongoDB database is established, the context deployment in the application server fails with the following error:

com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 0 ms

Of course in the same properties file you need to set up the connection details to your MongoDB database to store the monitoring data. Replace the following properties values with the correct ones:

mongo.host:localhost
mongo.port:27017
mongo.username:
mongo.password:


mongo.username and mongo.password are not mandatory. Leave them blank if your database doesn't require authentication.
Now you can package the WAR file:

mvn package

Then deploy it in your application server. I used Jetty 8.1.3 for this activity, so it was a simple copy and paste of the WAR file in its webapps folder and a start of the server.
To access the Mongobird dashboard open a web browser and go the following URL:

http://localhost:<port>/tetrad/

The login splash screen should show:



At first usage enter the following credentials to login:

ID: admin
PW: admin

and once logged in create your own users.

Comments

Popular posts from this blog

Exporting InfluxDB data to a CVS file

Sometimes you would need to export a sample of the data from an InfluxDB table to a CSV file (for example to allow a data scientist to do some offline analysis using a tool like Jupyter, Zeppelin or Spark Notebook). It is possible to perform this operation through the influx command line client. This is the general syntax: sudo /usr/bin/influx -database '<database_name>' -host '<hostname>' -username '<username>'  -password '<password>' -execute 'select_statement' -format '<format>' > <file_path>/<file_name>.csv where the format could be csv , json or column . Example: sudo /usr/bin/influx -database 'telegraf' -host 'localhost' -username 'admin'  -password '123456789' -execute 'select * from mem' -format 'csv' > /home/googlielmo/influxdb-export/mem-export.csv

jOOQ: code generation in Eclipse

jOOQ allows code generation from a database schema through ANT tasks, Maven and shell command tools. But if you're working with Eclipse it's easier to create a new Run Configuration to perform this operation. First of all you have to write the usual XML configuration file for the code generation starting from the database: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">   <jdbc>     <driver>oracle.jdbc.driver.OracleDriver</driver>     <url>jdbc:oracle:thin:@dbhost:1700:DBSID</url>     <user>DB_FTRS</user>     <password>password</password>   </jdbc>   <generator>     <name>org.jooq.util.DefaultGenerator</name>     <database>       <name>org.jooq.util.oracle.OracleDatabase</name>     ...

Turning Python Scripts into Working Web Apps Quickly with Streamlit

 I just realized that I am using Streamlit since almost one year now, posted about in Twitter or LinkedIn several times, but never wrote a blog post about it before. Communication in Data Science and Machine Learning is the key. Being able to showcase work in progress and share results with the business makes the difference. Verbal and non-verbal communication skills are important. Having some tool that could support you in this kind of conversation with a mixed audience that couldn't have a technical background or would like to hear in terms of results and business value would be of great help. I found that Streamlit fits well this scenario. Streamlit is an Open Source (Apache License 2.0) Python framework that turns data or ML scripts into shareable web apps in minutes (no kidding). Python only: no front‑end experience required. To start with Streamlit, just install it through pip (it is available in Anaconda too): pip install streamlit and you are ready to execute the working de...