<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>maven-tomcat-plugin | Sajid Rahman</title>
    <link>https://www.cise.ufl.edu/~msr/tag/maven-tomcat-plugin/</link>
      <atom:link href="https://www.cise.ufl.edu/~msr/tag/maven-tomcat-plugin/index.xml" rel="self" type="application/rss+xml" />
    <description>maven-tomcat-plugin</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><copyright>© 2021 - Sajid Rahman</copyright><lastBuildDate>Sun, 13 Dec 2020 00:00:00 +0000</lastBuildDate>
    <image>
      <url>https://www.cise.ufl.edu/~msr/media/icon_hu257dded1a2315d693952aa7ac83b6d59_5868_512x512_fill_lanczos_center_3.png</url>
      <title>maven-tomcat-plugin</title>
      <link>https://www.cise.ufl.edu/~msr/tag/maven-tomcat-plugin/</link>
    </image>
    
    <item>
      <title>Deploying in Apache Tomcat via Maven-Tomcat plugin</title>
      <link>https://www.cise.ufl.edu/~msr/post/maven-tomcat-deployment/</link>
      <pubDate>Sun, 13 Dec 2020 00:00:00 +0000</pubDate>
      <guid>https://www.cise.ufl.edu/~msr/post/maven-tomcat-deployment/</guid>
      <description>&lt;ol&gt;
&lt;li&gt;Add the following user-roles and user (specially a user with roles of &lt;code&gt;manager-jmx,manager-script&lt;/code&gt;, see &amp;lsquo;maven&amp;rsquo; user, for example) in tomcat-users.xml file. (Sidenote: you can create a user with &lt;code&gt;manager-gui&lt;/code&gt; role to access Tomcat manager interface from your browser, that&amp;rsquo;s pretty cool and handy!!)&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&#34;language-xml&#34;&gt;&amp;lt;!--This file is located in %TOMCAT_HOME%/conf/tomcat-users.xml --&amp;gt;
&amp;lt;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?&amp;gt;
&amp;lt;tomcat-users&amp;gt;

  &amp;lt;role rolename=&amp;quot;manager-gui&amp;quot;/&amp;gt;
  &amp;lt;role rolename=&amp;quot;manager-script&amp;quot;/&amp;gt;
  &amp;lt;role rolename=&amp;quot;manager-jmx&amp;quot;/&amp;gt;
  &amp;lt;user username=&amp;quot;admin&amp;quot; password=&amp;quot;tomcat&amp;quot; roles=&amp;quot;manager-gui&amp;quot;/&amp;gt;
  &amp;lt;user username=&amp;quot;maven&amp;quot; password=&amp;quot;tomcat&amp;quot; roles=&amp;quot;manager-jmx,manager-script&amp;quot;/&amp;gt;

&amp;lt;/tomcat-users&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;Add above Tomcat’s user (&amp;lsquo;maven&amp;rsquo; user in this case) in the Maven setting file, later Maven will use this user to login Tomcat server.( N.B. In case of a project running in IntelliJ, view/create maven settings.xml file from POM &amp;ndash;&amp;gt; MAVEN &amp;ndash;&amp;gt; Open Settings.xml (Or Create Settings.xml, if settings.xml is not present).)&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&#34;language-xml&#34;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
&amp;lt;settings xmlns=&amp;quot;http://maven.apache.org/SETTINGS/1.0.0&amp;quot;
          xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;
          xsi:schemaLocation=&amp;quot;http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd&amp;quot;&amp;gt;
    &amp;lt;servers&amp;gt;

        &amp;lt;server&amp;gt;
            &amp;lt;id&amp;gt;TomcatServer&amp;lt;/id&amp;gt;
            &amp;lt;username&amp;gt;root&amp;lt;/username&amp;gt;
            &amp;lt;password&amp;gt;tomcat&amp;lt;/password&amp;gt;
        &amp;lt;/server&amp;gt;

    &amp;lt;/servers&amp;gt;
&amp;lt;/settings&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&#34;3&#34;&gt;
&lt;li&gt;Declare a maven-tomcat plugin in pom.xml.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&#34;language-xml&#34;&gt;	&amp;lt;plugin&amp;gt;
		&amp;lt;groupId&amp;gt;org.apache.tomcat.maven&amp;lt;/groupId&amp;gt;
		&amp;lt;artifactId&amp;gt;tomcat7-maven-plugin&amp;lt;/artifactId&amp;gt;
		&amp;lt;version&amp;gt;2.2&amp;lt;/version&amp;gt;
		&amp;lt;configuration&amp;gt;
			&amp;lt;url&amp;gt;http://localhost:8080/manager/text&amp;lt;/url&amp;gt;
			&amp;lt;server&amp;gt;TomcatServer&amp;lt;/server&amp;gt;
			&amp;lt;path&amp;gt;/mycoolapp&amp;lt;/path&amp;gt;
		&amp;lt;/configuration&amp;gt;
	&amp;lt;/plugin&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here, we are configuring maven-tomcat plugin to access TomcatServer with credentials defined in maven&amp;rsquo;s settings.xml file and deploy our app in this context path &lt;strong&gt;/mycoolapp&lt;/strong&gt;.&lt;/p&gt;
&lt;ol start=&#34;4&#34;&gt;
&lt;li&gt;
&lt;p&gt;Run Tomcat Server (from command line &lt;code&gt;%TOMCAT_HOME%/bin/startup.sh&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now execute this command in terminal after going to your project directory: &lt;code&gt;maven tomcat7:deploy&lt;/code&gt; to deploy your war file in Tomcat. You should get a &lt;strong&gt;BUILD SUCCESS&lt;/strong&gt; message if everything goes well.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
</description>
    </item>
    
  </channel>
</rss>
