How to deploy spring boot war in jboss

In this article, we will see what are different strategies to deploy spring boot applications. Spring Boot lets you focus mainly on application development without worrying about some common configurations you used to do in spring. You don’t even need to bother about deployment part while in development stage, thanks to its Embedded servlet container that comes along with spring-boot-starter-web dependency. Isn’t this interesting? We will start by developing a simple spring boot web application and then see how to deploy spring boot war in JBOSS server and some other application servers.

What you will learn??

  • Creating a simple Spring Boot application
  • Deploying to default embedded tomcat servlet container (tomcat 7)
  • Upgrading the embedded tomcat version to tomcat 8
  • Deploying to Jetty Embedded Servlet Container
  • Deploying to External tomcat server as a war
  • Deploying to jboss-eap-7.1 as a war

Tools & Technologies Used

Getting started with Spring Boot

There are different ways you can start creating applications in spring boot. You can use Spring Initializr web service at and fill all the required information to generate spring boot application. Or you can use your favorite IDE like IntelliJ IDEA or Eclipse or Pivotal provided STS-Spring Tool Suite. Its just a matter of choice. I will be using STS which is Eclipse-based development IDE that is customized for developing Spring applications. Now let us start the development.

Open STS IDE-> File menu -> New -> Spring Starter Project and fill the info as following.

Click on Next button and choose spring boot version, web dependency and hit Finish button.

HelloSpringBoot project will be created and we will customize the package structure and add few classes as the following.

What’s inside pom.xml ?

You will get the following dependencies in pom.xml.

Bootstrap your application

HelloSpringBootApplication class will bootstrap the spring boot application and starts an instance of default Embedded tomcat server. HelloSpringBoot app will automatically get deployed in this embedded tomcat server.

Lets create a simple Controller class with the name Add @RestController annotation at class level. @RestController is often used for APIs that serve JSON, XML, etc. Your controller methods will return an object that will be serialized to one or more of these formats. Know more about various spring-boot annotations at pivotal site.


@RequestMapping will create a route so that our application will be accessible at /hello/{name}. hello(-) method accepts one parameter and simply returns greeting message. String name is a path variable mapped with {name}. 


That’s all you need to start your deployment. But in case, you want to deploy this application on some other ports (default is 8080), simply add server.port=8081 this key-value in file as shown in the following.

Embedded Tomcat Server Deployment

If you are a novice and just started learning spring boot, you might be wondering that how this embedded tomcat server will be automatically started and how deployment process will happen. Cool !, don’t bother about this. Spring Boot is smart enough to do it for you. When you run HelloSpringBootApplication either as Java Application or Spring Boot App, Spring Boot uses public static void main as entry-point that launches an embedded web server for you. So, you see, there is no magic at all. Now that you know the process, run the HelloSpringBoot application as Spring Boot App (or Java Application), default embedded tomcat server will be started on the port configured. You must see Tomcat started on port(s): 8081 (http) with context path ‘ ‘  in the console. Your wait is over, now just invoke the following URL in your favorite browser to see the greeting message.


By default, Spring boot uses Tomcat 7. But if you want to use tomcat 8, for this you need to override the maven build’s tomcat.version in the <properties> tag of pom.xml file as the following.

Jetty Embedded Servlet Container

Now that we worked with embedded tomcat server, lets try to use Jetty Embedded Servlet Container this time. Jetty project has been hosted at the Eclipse Foundation since 2009. In order to use the jetty server, first we have to exclude spring-boot-starter-tomcat module and add spring-boot-starter-jetty module. Here is the revised pom.xml file (only dependencies part).

Now, simply run the application and you will notice Jetty started on port(s) 8081 (http/1.1) with context path ‘/’  in the console.

Deploying As WAR file on Java EE Application Servers

So far we discussed on deploying spring boot web application on embedded servers but what about typical Java EE Application servers like jboss, weblogic or external tomcat server. Working with embedded server is fine as long as you are working in development environment. But what about deploying it as typical war file in UAT or Production environment. Well, in that case you have to make certain changes. Now i will show how to deploy spring boot application on external tomcat server and also on jboss-eap-7.1 server as war file.

Spring Boot WAR + External Tomcat Deployment

So far we worked with different embedded servlet containers. First of all, we will try deploying to external tomcat. In order to deploy spring boot app as war on tomcat, we need to make following changes.

  • Change the packaging from jar to war
  • Exclude the embedded server container or mark it as provided.
  • Add servlet api dependency
  • Extends from SpringBootServletInitializer

Change the packaging from jar to war

If you remember, while creating the project, we have selected the packaging as jar. So change the packaging to war in pom.xml file.

Exclude the embedded server container or mark it as provided

Since we are going to deploy war to external tomcat , there is no need of embedded servlet container. So, there are two things we can do. Either we can mark the spring-boot-starter-tomcat dependency as provided or exclude it. I believe exclusion will be a good idea as marking it as provided will increase the size of war file that we will generate for deployment. This will make war file few megabytes smaller in size. So exclude the servlet container from spring-boot-starter-web as following in pom.xml.

Add servlet api dependency

We have to add servlet api related dependency in pom.xml and mark its scope as provided as following.

The revised pom.xml after all changes should finally look like the following.

Extends from SpringBootServletInitializer


To set up the application as a servlet we have to extend the main class with SpringBootServletInitializer and override the configure method using SpringApplicationBuilder. After changes, HelloSpringBootApplication class looks like
the following.


Generate the war file on tomcat server

This is the final step. We will create a war file with the help of maven build. Right click on HelloSpringBoot -> Run As -> Maven Build.. -> mention clean package as Goals -> Hit the Run button.

This will create a war file HelloSpringBoot-0.0.1.war in target folder of projects directory. Copy this war file in webapps folder of your tomcat installation and start your server. You will be able to access the following url with your configured port of your external tomcat.

Spring Boot WAR + JBOSS-EAP-7.1 Deployment

Now we will see how to deploy spring boot war in jboss-eap-7.1. I hope you have jboss-eap-7.1 installed on your machine. If not, get it downloaded from official redhat site. In order to download, you need to have account on redhat site. Its completely free to register.

Once downloaded, extract the zip file in your preferred location. Before getting into deployment part, we have to do few changes with respect to Jboss server deployment. First of all add the below key in file.

Second, we have to create jboss-web.xml that contains the context root configuration.

If your project directory does not already contain webapp/WEB-INF folder, create it and create a jboss-web.xml file with the following content.

Thats all you need to to. Now again generate war file with the help of maven build.

Once HelloSpringBoot-0.0.1.war is generated, copy this artifact to “jboss-eap-7.1.0\jboss-eap-7.1\standalone\deployments” directory. Double click on standalone.bat file to start the jboss server. If successfully deployed, HelloSpringBoot-0.0.1.war.deployed will be generated. Just make sure no other services are running on port 8080 as default port on which jboss server will be started is also 8080.

Now you will be able to access the spring boot app with the help of following url. Don’t be confused with SpringBoot in the url as it is the context-root we configured in jboss-web.xml file.


That’s all in this article. I hope you will like this. In case of any query, please feel to write in the comment section. Kindly support us by subscribing our blog if not done already. Have a good day. Happy Coding.


10 thoughts on “How to deploy spring boot war in jboss”

  1. Stanley Termini says:

    Howdy! I simply want to give a huge thumbs up for the good information you may have right here on this post. I will probably be coming back to your weblog for more soon.

    1. Chandra Mani Gupta says:

      Glad that you liked this post. Stay tuned for similar articles.

  2. anas says:

    This solution is not working for me

  3. Adoyi Abah Sunday says:

    my web context is still pointing to ‘/HelloSpringBoot-0.0.1-SNAPSHOT’ after i added jboss-web.xml

    1. Chandra Mani Gupta says:

      Kindly re-check once whether you have kept jboss-web.xml in webapp/WEB-INF folder of your project.

  4. Rishi Beohar says:

    I am still getting 404 found for the controller class.

    1. Chandra Mani Gupta says:

      Kindly post your controller class. You might be doing silly mistake somewhere.

  5. Pingback: Enable HTTPS with Self-Signed-Certificate in Spring Boot 2.0.2 - code-adda
  6. Trackback: Enable HTTPS with Self-Signed-Certificate in Spring Boot 2.0.2 - code-adda
  7. Avinash Anshu says:

    simple and best way to deploy the spring boot app through jboss.

    1. Chandra Mani Gupta says:

      Thank you Avinash, I am glad that this article helped you. Kindly subscribe our blog for more such important stuff…!!

Leave a Reply