Tuesday 28 October 2014

Run your Maven applications with TomEE plugin

If you are coding JEE applications you will probably need a server which allows you to quickly run and test your code.  If you are looking for a painless solution then TomEE might be your favorite choice. In particular if you are working with Maven projects.

At the moment the current version of TomEE is 1.7 which is based on Tomcat 7 and supports JEE6. The only thing you have to do is to include and configure the tomee-maven-plugin in your pom.xml:

<plugin>
   <groupId>org.apache.openejb.maven</groupId>
   <artifactId>tomee-maven-plugin</artifactId>
   <version>1.7.1</version>
   <configuration>
      <tomeeVersion>1.7.1</tomeeVersion>
      <tomeeClassifier>plus</tomeeClassifier>
      <synchronization>
         <extensions>
            <extension>.class</extension>
         </extensions>
      </synchronization>
      <reloadOnUpdate>true</reloadOnUpdate>
   </configuration>
</plugin>

Depending on the features you need TomEE supports different profiles. To start a TomEE server and run your application simply type

mvn clean install tomee:run

The synchronization block in the configuration is optional and allows you to redeploy your application automatically after each mvn clean install of your application.