Skip to main content

Posts

Showing posts with the label Tomcat

Gradle : How to use Gradle Cargo Plugin to Deploy war on Tomcat

This post is based on the Gradle Cargo Plugin by bmuschko Include the Plugin You need to include the plugin in your build.gradle . buildscript { repositories { jcenter() } dependencies { classpath 'com.bmuschko:gradle-cargo-plugin:2.2.3' } } apply plugin: 'com.bmuschko.cargo' buildscript block should be the first thing in the build.gradle file. Include the Gradle Cargo plugin dependencies Add the following in your gradle dependencies block dependencies { def cargoVersion = '1.4.5' cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion" , "org.codehaus.cargo:cargo-ant:$cargoVersion" } Define the Tomcat Container To deploy The war files to Tomcat you need to create a dsl by name cargo and define the mandatory containerId . Note ContainerId will define the version of tomcat you...

Tomcat : How to start Tomcat as a service on Windows 7,8,10

Step 1 : Download and Extract tomcat Download tomcat from the link in .zip format. Once download is complete extract the tomcat in the location you want, preferably C:\Tomcat\ . Step 2 : Install Tomcat as a Service Go to the tomcat directory C:\Tomcat\bin . in the address bar write cmd . This will open the command prompt window. Now in the command prompt window type the command service.bat install <Service -Name> Here <Service-Name> can be any name that you want to assign to your Service. When you run this command you will see the following output. Check the installed Service Now, lets see if the service is created or not. For this open Services . It will give the following screen. Configure Service to Run at Startup We can make the service to run on windows startup, for this, open the Service setting by double click on the service. It will open the following screen ...

Tomcat : How to start Tomcat on more than one Port.

How to start Tomcat on more than one Port. Tomcat settings can be found in TomcatFolder/conf/server.xml file. Root element of the configuration is Server tag. You can add multiple Service under Server tag for running tomcat on more than one port. Default Service Configuration should look as follows < Service name = "Catalina" > < Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> < Connector port = "8009" protocol = "AJP/1.3" redirectPort = "8443" /> < Engine name = "Catalina" defaultHost = "localhost" > < Realm className = "org.apache.catalina.realm.LockOutRealm" > < Realm className = "org.apache.catalina.realm.UserDatabaseRealm" resourceName = "UserDatabase" /> </ Realm > ...

Tomcat : How to change default port 8080 of Tomcat

How to change default port 8080 of Tomcat Look for the file server.xml in folder path-to-Tomcat/conf/ This file containes the configuration for tomcat. Look for the following lines in this file. < Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> Connector port="8080" defines the port on which the tomcat will run. If you want to run tomcat on any port other than 8080 then you can just change the port number here. e.g Running Tomcat on port 8090 < Connector port = "8090" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> e.g Running Tomcat on port 9000 < Connector port = "9000" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> Also Read How to c...

Tomcat : How to change Deployment directory from webapp to custom Directory.

How to change Working Directory of Tomcat to Custom Directory Default Tomcat working directory is webapp . If you want to change this to some other directory then you can follow the steps below. Open the server.xml file. You can find this file in conf/ directory of your tomcat folder. Find the following line in the file < Host name = "localhost" appBase = "webapps" unpackWARs = "true" autoDeploy = "true" > It states the following things name="localhost" - name of the server appBase="webapps" - working directory of tomcat where applications are deployed unpackWARs="true" - if tomcat should unpack war files. autoDeploy="true" - if tomcat should auto deploy changes How to change Work directory of tomcat. To change the work directory from webapp to some other directory you can give the absolute path to the directory where you want to deploy apps. relative path to the directory...

How to create SSL Certificate and add it to Keystore

Points To Remember You need to have a SSL certificate o run an application/ server on https. You can create a SSL certificate using keytool. The keystore file for Java is available in Java/jre/lib/security/cacerts. Default password of the keystore is "changeit". Create a Keystore You can make a SSL certificate by following the steps below. Open a Command-line or Terminal window and make sure you're in your home directory. Execute the following command in the terminal keytool -genkey -alias tomcat -keyalg RSA -validity 365 NOTE, the validity parameter allows you to specify, in the number of days, how long the certificate should be valid for. The longer the time period, the less likely you are to need to recreate it. To recreate it, you'd need to delete the old one and then follow these instructions again. The response will look something like this: Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: $MACHINE_NAME What is the ...

How to Deploy a war on Tomcat

Points To Remember You should have a war file that can be deployed to the tomcat. You should have tomcat installed on your machine. Deploying a war file on Tomcat. We hope you have a installed the tomcat or have the tomcat bundle extracted on your system. In your case we just downloaded the tomcat zip and unzipped at home location. Step 1 : Change Tomcat User Name Password and Roles This is done so that you can login to the Tomcat Application Manager . All you need to do is find the file tomcat-user.xml at location path-to-tomcat/conf . Replace the following lines <!-- <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> --> with the following lines < rol...