configure the embedded tomcat, embedded, embedded tomcat, embedded tomcat7, embedding tomcat, tomcat maven plugin

Leveraging Embedded Tomcat in Maven Application

In java when we develop a web application, we go for installation of tomcat on intended system. And then we deploy the application on tomcat for running it or for accessing it from the browser.
How about developing an application which can directly run on the intended system without installation of tomcat? Is it really achievable?
Yes, this can be easily achieved through Maven plug-in. Let us see how!
You might be puzzled as to how this is possible to run a web application without the installation of web container. Let us quickly have a look at the procedure which is pretty simple.
To accomplish this you just need to use a maven plug-in in pom.xml file of application. This plugin simply embed the tomcat inside the application and on build of application it generates an executable jar file, which can be easily executed by the java jar command and you can access the application on browser.
Please follow the below detailed step-by-step procedure:
1.   Add the following plugin in your pom.xml file:
2.     Build your application: Build your application using the install or package goal. This will generate the 3 extra files in application target folder.


    a.  yourappname-version-exec-war.jar: An executable jar file with embedded tomcat. 
    b. war-exec.manifest:  Manifest file contains Main class name. 
    c. A properties file contains the tomcat information and some configuration options.
3.     Run your application: Once you are ready with the above three files, execute the below command to run the application.
 java –jar yourappname-version-exec-war.jar


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s