Monthly Archives March 2014

How to Build an Executable War or Jar Files

Posted by admin on March 26, 2014  /   Posted in J2EE, Web Development

Background

In the effort to bend-over-backwards for our clients, we sometimes have to take a step back and think outside of the box.

99% of our Custom System are deployed as a web applications whether it is hosted on our server or the client’s. But for this particular client, they require a way to deploy the application on an isolated machine.  So we had to improvise a way to package a webserver *and* the application into something that can be donwloaded, and run without any complicated setup.

Sharing our Findings

So here is a simple way I found to make my maven webapp project into a self-executing jar file. Glad to share it for all to take advantage of. This has the obvious advantage of not having to setup a Tomcat server on each client that will use the application. And since an executable .jar files are OS independent, you can use this whether you are a Windows or UNIX shop.

Requirements:
1) Client needs to have Java installed
2) Your project must have a packaging pom or war.
3) Your web app should already be working and can compile without error.
4) This is only supported with the Tomcat7 plug-in

Now go into your pom.xml file and add the plug-in with your other plug-ins.

Here’s the code for the Maven plug-in:

<project>
 ...
 <packaging>war or pom</packaging>
 ...
 <build>
 ...
 <plugins>
 ...
 <plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.1</version>
 <executions>
 <execution>
 <id>tomcat-run</id>
 <goals>
 <goal>exec-war-only</goal>
 </goals>
 <phase>package</phase>
 <configuration>
 <path>/</path>
 <!-- optional only if you want to use a preconfigured server.xml file -->
 <serverXml>src/main/tomcatconf/server.xml</serverXml>
 <!-- optional values which can be configurable -->
 <attachArtifactClassifier>default value is exec-war but you can customize</attachArtifactClassifier>
 <attachArtifactClassifierType>default value is jar</attachArtifactClassifierType>
 </configuration>
 </execution>
 </executions>
 </plugin>
 ...
 </plugins>
 ...
 </build>
 ...
 </project>

This plug-in code is from the Apache site. I usually remove the server.xml option and I will set the ArtifactClassifier and ArtifactClassifierType to ‘exec-war’ and ‘jar’ respectively. But it should work will all the optional tags removed.

After you have your pom.xml file saved, drill your command line to folder that has the pom.xml file and run the following command:

mvn clean package -Prunnable-war

Things to note with this command.

  1. There is no space between the ‘-P’ argument and the name of the profile
  2. The ‘runnable-war’ is just a generic profile name. You will use the name of your profile that is in the pom.xml file. If you have more than one build then select the most appropriate. I usually have a ‘dev’, ‘test’ and ‘prod’ profiles. I typically use the ‘dev’

Once the command has been completed 3 new files will be created.

  • ${yourapp-version-war-exec}.jar: A runnable JAR that contains the tomcat embedded runtime
  • war.exec.manifest: a manifest file containing the main class to run
  • war-exec.preperties: a properties file containing some Tomcat config options and info.

NOTE: If your project has multiple modules then these 3 new files will be created in each folder.
For example, I typically have 5 folders for my web apps.

my-project
 |
 ---- my-project-common
 |
 ---- my-project-engine
 |
 ---- my-project-test
 |
 ---- my-project-web

I create the jar with the parent pom.xml, but the 3 new files that I will use are going where my web app is. (‘my-project-web’)

So for the final step, go into the target folder of your web app (‘my-project-web’ in my case) and run the following command to start the Tomcat server:

java -jar ${yourapp-version-war-exec}.jar

Open up a browser and go to http://localhost:8080 and your app should be there.
First run is usually slow to start because of all the extraction that happens.

Now you can simply copy these three files to another computer that has Java and start you web app with the same command.

Esteban Martinez
Senior Developer

School Districts are Putting Up Dashboards

Posted by admin on March 13, 2014  /   Posted in BI and Custom Development

Think Dashboards are only for Executives and Businesses?

Well, think again.

Today, even school districts are doing it.  First, let me be clear, it should come to no surprise that organizations within the education sector, especially the ones focusing on educating our children, should take advantage of any information technologies available today.

What really surprised me is how they use the Dashboard. Have a look here:

The Plano Independent School District (PISD) put up a dashboard which compares them with the neighboring cities’ ISD. The above image is just one of the elements on the Dashboard, by the way.  The rest of it looks just as impressive, as they seem to use every bells-and-whistles available in the charting world (not necessarily the best approach, but at least it is out there serving some purpose).

But while the Dashboard is put-together well, what impressed me the most is that the ISD gets it. They know that in order to get ahead of their peers, they not only have to perform, but also take the time to showcase their achievements.

This realization puts them — quite sadly — ahead of how most business owners think today.

Where does the data come from?

Or more importantly, how hard or how easy it is to put up the Dashboard, given the limitation of resources and information.  And this is what makes the situation even more ironic. We are living in the golden era of publicly accessible information. What is not available from within the organization, could easily be obtained either through some governing bodies or data collected independently.

And if a business owner still think that it is impossible for them to get the data about their competitors or customers or vendors/suppliers or everything else, that’s an outdated view and should be discarded.

What is it really for?

To make it easier for interested parties to make decisions. In this particular case, the interested parties are parents of students or young people who are looking for a place to move into or to start their lives.  By utilizing the Dashboard to serve relevant information in various dimension, the Plano ISD has make it that much easier for people to consider their options.

The same case can be made strongly for almost every businesses out there. When people are considering your products and businesses, the more ways you can showcase your distinguishing features, the more you can grab the mind of interested parties (read: potential customers).

Go Publish!

With today’s technologies, and the accessibility of potentially relevant external data, for example the General Society Survey, or  The Gapminder site, and many more, it is a crime not to have your own Business Dashboards. As the ISD’s have shown, an effort to present relevant up-to-date and relevant information is not limited to a one-shot deal, it is a continuous, planned, and deliberate program that should be included in your day-to-day business operations.


We serve businesses of any type and size
Contact Us Today