How to Install Jetty Application Server

Jetty is an open-source Servlet container and Application Server which is known to be lightweight, portable, robust, flexible, extensile and providing patronize for assorted technologies like SPDY, WebSocket, OSGi, JMX, JNDI, and JAAS. Jetty is very convenient for development and besides wide used in production environments. In this post, we are going to detail how to install and configure a Jetty Server. We are first going to describe how to setup and run a standalone Jetty. Thereafter we will mention some configuration options and skim through the modular architecture of Jetty. breakwater presents Standalone, Embedded and Jetty Maven Plugin modes of operation. In this stake we are going to use standalone Jetty.

1. Environment

In this post, we are going to use following environment :

  • Java 8
  • Jetty 9.3.2.v20150730

however, it should be noted that ; the material presented in this post is applicable for any Java versions late than Java 5, and any Jetty installations of interpretation 9.x.y. breakwater does not require any 3rd party libraries except having Java installed in your PATH .

2. Downloading Jetty

breakwater binaries can be downloaded from the Jetty Homepage. Binaries are available in zip and tgz formats. Jetty is fully cross-platform so lapp binaries are valid for both Java and Unix environments .

3. Running Jetty

After downloading the binaries, having your breakwater server up and running is truly easy. First you have to extract the zip ( or tgz ) archive to a commodious directory. After extracting the binaries, you have to navigate to the directory ( jetty-distribution-9.3.2.v20150730 in this model ). We will call it JETTY_HOME  from now on in this post. In JETTY_HOME you have to run the following carapace command in regulate to start Server :

java -jar start.jar

This command yields to following output :

2015-08-30 20:57:07.486:INFO::main: Logging initialized @361ms
2015-08-30 20:57:07.541:WARN:oejs.HomeBaseWarning:main: This instance of Jetty is not running from a separate {jetty.base} directory, this is not recommended. See documentation at http:www.eclipse.orgjettydocumentationcurrentstartup.html
2015-08-30 20:57:07.688:INFO:oejs.Server:main: jetty-9.3.2.v20150730
2015-08-30 20:57:07.705:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:Usersibrahimjcgexamplesjettyjetty-distribution-9.3.2.v20150730webapps] at interval 1
2015-08-30 20:57:07.729:INFO:oejs.ServerConnector:main: Started ServerConnector@7a1d7e18{HTTP1.1,[http1.1]}{0.0.0.0:8080}
2015-08-30 20:57:07.730:INFO:oejs.Server:main: Started @606ms

Seeing the concluding line like 2015-08-30 20:57:07.730:INFO:oejs.Server:main: Started @606ms means that : you have successfully started Jetty. In order to verify successful begin you can navigate to http : //localhost:8080/ and see the following reception :

4. Running Web Applications In Jetty

It is very to install your web applications ( WARs ) in Jetty. All you have to do is dropping the WAR file under JETTY_HOME/webapps. You do not even need to restart Jetty. webapps directory is monitored sporadically and fresh applications are deployed automatically .

5. Anatomy of the JETTY_HOME Directory

When you examine the capacity of the JETTY_HOME you will see take after directories :

  • bin
  • demo-base
  • etc
  • lib
  • logs
  • modules
  • resources
  • start.d
  • webapps

Some of these directories are worth mention :

  • etc: The XML configuration of Jetty modules defined in this directory.
  • lib: As in most Java applications, JAR files are stored in lib directory.
  • logs: When logging is enabled, log files are created under this directory.
  • modules: Jetty modules are defined under modules directory
  • resources: The external configuration resources (like logging configuration resources) are usually placed under this directory.
  • start.d: The modules activated through command line are configured through this directory.
  • webapps: The web applications (WAR files) running in our Jetty Server are dropped in this directory.

In JETTY_HOME directory, start.ini and start.jar files exist start.ini is the shape file where most Jetty shape is performed. start.jar is the initial feasible file that initiates inauguration of the server.

6. Basic Configuration

6.1 Changing the Jetty Port

By default, Jetty runs on 8080. In decree to change it to 7070 or some early port, you have to do the comply :

  1. Open start.ini under JETTY_HOME.
  2. Add this line jetty.port=7070
  3. Save and close the file.

When you start the Jetty again it will run on port 7070 .

6.2 Changing the webapps Directory

JETTY_HOME/webapps is the nonpayment directory to deploy your applications. If you need to change it for some cause, the steps to be followed are as follows :

  1. Open the start.ini.
  2. Remove the comment before the parameter jetty.deploy.monitoredDirName
  3. Change this parameter as you wish( E.g: jetty.deploy.monitoredDirName=../webapps2 )
  4. Save and close the file.

now we can put our WARs in the webapps2 directory, which is at the lapp tied as our JETTY_HOME

7. Modular Architecture of Jetty

Jetty runs on a modular architecture which means that many facilities and integrations are presented as modules. HTTP, HTTPS, SSL, logging, JMX, JNDI, WebSockets and many early features are implemented as separate modules. Some park modules such as HTTP, JSP and WebSocket are activated by default. The others ( such as HTTPS, JMX etc. ) have to be activated manually .

7.1 Anatomy of a Single Module

The modules are listed under JETTY_HOME/modules directory as mod files. mod files state the needed JAR files to be activated ( which are under JETTY_HOME/lib directory ) and XML configuration files ( which are under JETTY_HOME/etc directory ) and other resources to be activated as the module is activated. For exemplar, when you view JETTY_HOME/modules/logging.mod content of, you will see something like the postdate :

[ xml]

etc/jetty-logging.xml
[files]
logs/
[lib]
lib/logging/**.jar
resources/

The configuration states that logging is configured through etc/jetty-logging.xml ; and required JARs are under lib/logging. In summation to these, logs directory is required for this faculty .

7.2 Activating Modules through Command Line

There are two ways to activate Jetty modules. The beginning direction is activating through command note :

java -jar start.jar --add-to-startd=logging

The command above creates the file logging.ini under JETTY_HOME. Related shape can be found in this file. After configuring log, you can start Jetty again and observe that log is active .

7.3 Activating Modules through start.ini

The moment way to activate a module is adding the module to the start.ini :

--module=logging

This is equivalent to the command line presented in the first gear alternative with a elusive difference. This time, nothing is created under start.d ; so all far shape should be done in this same start.ini file. personally, I would prefer the second alternative since all active modules are listed in a individual file ( start.ini ) however there is no problem with the first approach path either.

7.4 Configuring the Modules

As mentioned above, mod files tell us about the relevant XML shape files, which are under JETTY_HOME/etc, for the module. Jetty modules are configured through these XML files. For exercise logging module states jetty-logging.xml is relevant for logging shape. One can alter this file to modify logging shape .

8. Conclusion

In this station, we have defined the associate steps to install and configure a standalone Jetty waiter. foster information can be obtained through the official software documentation of Jetty .

reference : https://thefartiste.com
Category : Tech

About admin

I am the owner of the website thefartiste.com, my purpose is to bring all the most useful information to users.

Check Also

articlewriting1

Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.