<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Varshith V</title>
    <description>The latest articles on DEV Community by Varshith V (@varshithv).</description>
    <link>https://dev.to/varshithv</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F614869%2F8b334227-03ba-4a7a-bb4d-a07a9f19a4ad.png</url>
      <title>DEV Community: Varshith V</title>
      <link>https://dev.to/varshithv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/varshithv"/>
    <language>en</language>
    <item>
      <title>Migration of Java / Spring Boot Applications: From Weblogic to Tomcat Server</title>
      <dc:creator>Varshith V</dc:creator>
      <pubDate>Thu, 15 Apr 2021 13:39:06 +0000</pubDate>
      <link>https://dev.to/varshithv/migration-of-java-spring-boot-applications-from-weblogic-to-tomcat-server-jpd</link>
      <guid>https://dev.to/varshithv/migration-of-java-spring-boot-applications-from-weblogic-to-tomcat-server-jpd</guid>
      <description>&lt;p&gt;&lt;strong&gt;Oracle WebLogic&lt;/strong&gt; Server is a scalable, enterprise Java platform application server for Java-based web applications. It is popular within the commercial sphere — where companies require reliable software that comes with enterprise support.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Apache Tomcat&lt;/strong&gt; is an open-source Java servlet container that implements many Java Enterprise Specs such as the Websites API, Java-Server Pages and last but not least, the Java Servlet. Tomcat is the lightweight server, ideal for modern deployments including Docker, Kubernetes and Cloud deployments.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why migrate from Weblogic to Tomcat?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Reduce complexity&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Weblogic is complicated, both to program and to administer.&lt;/li&gt;
&lt;li&gt;Development, debugging and deployment in Weblogic takes more time. It is too heavyweight.&lt;/li&gt;
&lt;li&gt;Tomcat is faster at tasks such as redeployment. It focuses on essential features.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Reduce operation costs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maintaining Weblogic is very costly. One significant cost is licensing.&lt;/li&gt;
&lt;li&gt;The hardware required to support a Weblogic instance and the associated space/power/cooling costs are high.&lt;/li&gt;
&lt;li&gt;Typical Tomcat operating costs are estimated at ¼ to ⅙ the cost of Weblogic&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic Scaling of WebLogic application server is challenging, as WebLogic deployment architecture is complex.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Checklist to determine migration suitability
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Factor&lt;/th&gt;
&lt;th&gt;Migrate to Tomcat?&lt;/th&gt;
&lt;th&gt;Next Steps&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Application has been developed using Tomcat as runtime during development&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Determine configuration and deployment changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application primarily uses servlets and/or JSPs&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Check if app leverages any WebLogic-specific services and identify their equivalent replacements for Tomcat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application uses Spring framework&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Determine configuration and deployment changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application is written to be strictly standards-compliant&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Determine if other Java EE technologies are used and identify equivalent replacements for Tomcat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application is a third-party software, that is also available for Tomcat&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Obtain the Tomcat version of the web application and deploy it in Tomcat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application uses EJB or other WebLogic server functionality, not readily available for Tomcat&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Need code refactoring to remove the use of such functionality. This is preferably a “new application”, not a migration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Regular Java Applications (Non - Spring Boot):
&lt;/h2&gt;

&lt;p&gt;There are well known differences in the web application configuration and file layout conventions between WebLogic and those of the Java servlet specification standard. Making your application more standards-compliant makes it suitable to run on Tomcat.&lt;/p&gt;

&lt;p&gt;Items to check and migrate to the Java Servlet standard:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the web application has JSPs, make sure that any references to &lt;code&gt;java.util.*&lt;/code&gt; packages have corresponding statements in the JSP file.&lt;/li&gt;
&lt;li&gt;Make sure the root of the web application directory includes a WEB-INF directory with a &lt;code&gt;web.xml&lt;/code&gt; file inside it. The XML in this file needs to declare your mappings from any &lt;code&gt;weblogic.properties&lt;/code&gt; file you had. &lt;/li&gt;
&lt;li&gt;If you were already using a &lt;code&gt;web.xml&lt;/code&gt; file for WebLogic, you will likely have to scrub it for nonstandard elements and attributes and find the standard way of doing the same thing. Tomcat will point these out to you.&lt;/li&gt;
&lt;li&gt;Move your classes directory (if you have one) from the root of your web application to &lt;code&gt;WEB-INF/classes&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Move any JSP files from your &lt;code&gt;jspfiles&lt;/code&gt; directory (if you have one) into the root of your web application’s directory. Tomcat requires them in the root of your web application.&lt;/li&gt;
&lt;li&gt;Move any JAR files bundled by your web application to &lt;code&gt;WEB-INF/lib&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Remove or stub out any code in your web application that imports/uses the &lt;code&gt;com.bea.*&lt;/code&gt; or &lt;code&gt;com.weblogic.*&lt;/code&gt; packages.&lt;/li&gt;
&lt;li&gt;If the web application uses an “invoker” servlet, where the servlet isn’t mapped anywhere in the &lt;code&gt;web.xml&lt;/code&gt; file, and the servlet is still invoked via a URI such as &lt;code&gt;/servlets/com.myCompany.myServlet&lt;/code&gt;. Tomcat comes with an invoker servlet that is turned off by default. If you need to use it, refer the Tomcat documentation to enable it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above steps needs to be followed to make the application suitable for deployment in an external tomcat server.&lt;/p&gt;

&lt;h4&gt;
  
  
  Challenges
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;If you are targeting to deploy the application in an embedded tomcat server, Spring Boot framework is the ideal way. &lt;/li&gt;
&lt;li&gt;But for some reason, if you cannot move to spring boot, then you will need extra efforts. You will have to write a solution to embed the Tomcat server in your application using tomcat-embed API&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Spring Boot Applications
&lt;/h2&gt;

&lt;p&gt;The spring boot applications can be either deployed on an embedded tomcat server or a standalone tomcat server.&lt;/p&gt;

&lt;h5&gt;
  
  
  Embedded Tomcat Server
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This makes it easier to run the app without installing/configuring an external server during development and deployment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The generated jar file will include a Tomcat server within, making it possible to run the application with just a java runtime.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is the preferred approach to containerize the application with Docker and deploy the container into a container-hosted environment such as Kubernetes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Standalone / External Tomcat Server
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This is the traditional way. You have a war file, which will be used to deploy the application on an external tomcat installation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Here, one Tomcat installation can have many applications running in it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any &lt;code&gt;weblogic.properties&lt;/code&gt; file you had will not be used in Spring Boot. If there is any required configuration, move it to &lt;code&gt;application.properties&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;For all the changes required to migrate from Weblogic to Tomcat, the steps for both Embedded Tomcat and Standalone Tomcat are provided.&lt;/p&gt;

&lt;h3&gt;
  
  
  Changes in dependencies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;By default, Spring Boot has embedded Tomcat server included.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;spring-boot-starter-web&lt;/code&gt; dependency, which is used in almost all Spring Boot based applications, includes the Embedded-Tomcat dependency &lt;code&gt;spring-boot-starter-tomcat&lt;/code&gt; within.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the WebLogic app, they would have explicitly excluded this Tomcat dependency in &lt;code&gt;pom.xml&lt;/code&gt; file as shown below.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework.boot&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-boot-starter-web&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;exclusions&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;exclusion&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework.boot&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-boot-starter-tomcat&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/exclusion&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/exclusions&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  For Embedded Tomcat
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Remove the &lt;code&gt;&amp;lt;exclusions&amp;gt;&lt;/code&gt; tag  and its contents, to add back the embedded Tomcat dependency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Here we use jar packaging for deployment. From pom.xml, remove the line &lt;code&gt;&amp;lt;packaging&amp;gt;war&amp;lt;/packaging&amp;gt;&lt;/code&gt;, if present.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Please note that when no packaging is declared, Maven assumes the artifact is the default: jar.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  For Standalone Tomcat
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;We need to ensure that the embedded servlet container does not interfere with the servlet container to which the war file is deployed. &lt;/li&gt;
&lt;li&gt;To do so, you need to mark the embedded servlet container dependency as being “provided” in &lt;code&gt;pom.xml&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- … --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework.boot&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-boot-starter-tomcat&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;provided&lt;span class="nt"&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- … --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Here, we use WAR packaging for deployment. Declare the packaging type ‘war’ in pom.xml file as follows:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.0.1-your-app-version &lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;packaging&amp;gt;&lt;/span&gt;war&lt;span class="nt"&gt;&amp;lt;/packaging&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;name&amp;gt;&lt;/span&gt;your-app-name&lt;span class="nt"&gt;&amp;lt;/name&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Changes in ServletInitializer:
&lt;/h3&gt;

&lt;p&gt;In a Spring Boot application deployed to WebLogic, the servlet extends SpringBootServletInitializer and this initializer directly implements WebApplicationInitializer.&lt;/p&gt;

&lt;p&gt;This can be either found in the main class with &lt;code&gt;@SpringBootApplication&lt;/code&gt; itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.boot.autoconfigure.SpringBootApplication&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.boot.web.servlet.support.SpringBootServletInitializer&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.WebApplicationInitializer&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@SpringBootApplication&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyApplication&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;SpringBootServletInitializer&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; 
&lt;span class="nc"&gt;WebApplicationInitializer&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="nc"&gt;SpringApplicationBuilder&lt;/span&gt; &lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SpringApplicationBuilder&lt;/span&gt; 
     &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sources&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Application&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;SpringApplication&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Application&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, this can be found in a separate class as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.boot.builder.SpringApplicationBuilder&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.boot.web.servlet.support.SpringBootServletInitializer&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ServletInitializer&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;SpringBootServletInitializer&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;WebApplicationInitializer&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="nc"&gt;SpringApplicationBuilder&lt;/span&gt; &lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SpringApplicationBuilder&lt;/span&gt; 
     &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sources&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ServerTestApplication&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In either cases, follow these steps and make changes to one of the classes.&lt;/p&gt;

&lt;h5&gt;
  
  
  For Standalone Tomcat:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;We do not need the implementation of WebApplicationInitializer. Remove this &lt;code&gt;implements WebApplicationInitializer&lt;/code&gt; statement.&lt;/li&gt;
&lt;li&gt;Make sure that SpringBootServletInitializer is extended and overrides the configure method as in above code snippet.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  For Embedded Tomcat:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;We do not need the implementation of WebApplicationInitializer. Also we don’t need to extend the SpringBootServletInitializer, which means to remove the overridden configure method as well. &lt;/li&gt;
&lt;li&gt;The resulting main class should be of the default format:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@SpringBootApplication&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyApplication&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;SpringApplication&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Application&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;//Other methods, beans, etc.&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you had a separate ServletInitializer class, that class can be removed as it is not required anymore.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deployment
&lt;/h3&gt;

&lt;p&gt;Generate the deployable jar/war file using Maven. &lt;/p&gt;

&lt;p&gt;Run the following commands at project-root folder, to generate jar/war files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mvn clean
mvn install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can alternatively use IDE maven tools to generate jar/war files.&lt;br&gt;
This creates a jar/war file at the path {project-root}/target.&lt;/p&gt;

&lt;h5&gt;
  
  
  For Embedded Tomcat:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Use the generated jar file to deploy the application. This jar can be run using just a java runtime, without a server configuration. &lt;/li&gt;
&lt;li&gt;You can easily containerize this application, using Docker.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  For Standalone Tomcat:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use the generated war file to deploy the application in an external Tomcat server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;NOTE: The version of tomcat present in your dependency tree must be the same as your installed external Tomcat version. This can be resolved in 2 ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check the tomcat version in the dependency tree and install the same version externally for deployment.&lt;/li&gt;
&lt;li&gt;If you need to keep a specific version of external tomcat, you can also change the version used in the app by specifying it in pom.xml. But this method might give rise to cascading errors, which needs to be resolved.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt; &lt;span class="nt"&gt;&amp;lt;properties&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;java.version&amp;gt;&lt;/span&gt;11&lt;span class="nt"&gt;&amp;lt;/java.version&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tomcat.version&amp;gt;&lt;/span&gt;10.0.5&lt;span class="nt"&gt;&amp;lt;/tomcat.version&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/properties&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;If your application successfully ran on Tomcat, Kudos! You have successfully broken the vendor lock-in for the goodness of open-source.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

</description>
      <category>java</category>
      <category>tomcat</category>
      <category>weblogic</category>
      <category>server</category>
    </item>
  </channel>
</rss>
