WildFly(JBoss) vs. Tomcat

Introduction
Both WildFly and Tomcat are Java application servers, but they have difference strength. Making the wrong choice can result in more work than necessary.

The JBoss application server (aka JBoss AS) is an application server based on Java. It is an open source software server and is usable in any operating system supported Java (because the server is Java based).

Apache Tomcat is a servlet container (meaning it is a Java class that operates under the strictures of the Java Servlet API – a protocol by which a Java class responds to an http request). This is an open source server, providing a ‘pure Java’ HTTP web server environment in which code written in Java is capable of running.

The major difference between Wildfly and Tomcat
Both JBoss and Tomcat are Java servlet application servers, but JBoss is a whole lot more. The substantial difference between the two is that JBoss provides a full Java Enterprise Edition (JEE) stack, including Enterprise JavaBeans and many other technologies that are useful for developers working on enterprise Java applications.

Tomcat is much more limited. One way to think of it is that JBoss is a JEE stack that includes a servlet container and web server, whereas Tomcat, for the most part, is a servlet container and web server.

On the other hand, Tomcat has a lighter memory footprint (~60-70 MB), while those Java EE servers weigh in at hundreds of megs. Tomcat is very popular for simple web applications, or applications using frameworks such as Spring that do not require a full Java EE server. Administration of a Tomcat server is arguably easier, as there are fewer moving parts.

When WildFly
JBoss is the best choice for applications where developers need full access to the functionality that the Java Enterprise Edition provides and are happy with the default implementations of that functionality that ship with it. If you don’t need the full range of JEE features, then choosing JBoss will add a lot of complexity to deployment and resource overhead that will go unused. For example, the JBoss installation files are around an order of magnitude larger than Tomcat’s.

When Tomcat
Tomcat is a Java servlet container and web server, and, because it doesn’t come with an implementation of the full JEE stack, it is significantly lighter weight out of the box. For developers who don’t need the full JEE stack that has two main advantages.

Significantly less complexity and resource use.

Modularity.

For those who need add-ons that work with Tomcat, there are some lightweight alternative to JEE like EJB.

Summary
WildFly is a application servers with access to the whole JEE stack while Tomcat is servelet server

Developers of complex Java enterprise applications should choose JBoss (or GlassFish), while those who don’t need the full JEE stack are better off with Tomcat plus any extensions they need.

JBoss makes use of the Java EE specification; Tomcat makes use of Sun Microsystems specific specifications.

Referece
http://stackoverflow.com/questions/3821640/what-is-difference-between-tomcat-and-jboss-and-glassfish

JBoss vs. Tomcat: Choosing A Java Application Server

Difference Between JBoss and Tomcat

VisualVM

How to Evaluate the Performance (CPU + Memory) of java Software:

java -Dcom.sun.management.jmxremote.port=9011 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -cp “.:../lib/*:../../../../lib/*” it.AppListener > /var/log/AppListener.log 2>&1 &

or
export JAVA_OPTS=”-server -Xms6144M -Xmx7168M -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false”

after set the port variable during the start up of the software, is possible to use to evaluate the situation this software

Linux command to check which process takes memory

ps aux  | awk '{print $6/1024 " MB\t\t" $11}'  | sort -n

 

Where to download VisualVM

Deploy a Spring Boot application under Tomcat Web Server Container

Higthligths:
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}

public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}

}

pom.xml

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>



</dependencies>

Spring boot provides option to deploy the application as a traditional war file in servlet 3.x(without web.xml)supporting tomcat server.Please see spring boot documentation for this. I will brief what you need to do here.

step 1 : modify pom.xml to change the packaging to war:(that you already did)

<packaging>war</packaging>

step 2 : change your dependency

    <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
   </dependency>

to

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <scope>provided</scope>
</dependency>

step 3 :modify your war name (if you need to avoid the version details appended with the war name) in pom.xml under <build> tag.

<build>
    <finalName>web-service</finalName>
.....

step 4 : run maven build to create war : clean install step 5 : deploy the generated war file web-service.war in tomcat and request url in browser http://<tomcat ip>:<tomcat port>/web-service/hello

 

here the project : http://gitlab.saic.it/root/spring-boot-war-tomcat