avaje-jetty-runner


License

License

Categories

Categories

Jetty Container Application Servers
GroupId

GroupId

org.avaje.jetty
ArtifactId

ArtifactId

avaje-jetty-runner
Last Version

Last Version

2.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

avaje-jetty-runner
avaje-jetty-runner
Project URL

Project URL

http://avaje.org
Source Code Management

Source Code Management

https://github.com/avaje-common/avaje-jetty-runner.git

Download avaje-jetty-runner

How to add to project

<!-- https://jarcasting.com/artifacts/org.avaje.jetty/avaje-jetty-runner/ -->
<dependency>
    <groupId>org.avaje.jetty</groupId>
    <artifactId>avaje-jetty-runner</artifactId>
    <version>2.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.avaje.jetty/avaje-jetty-runner/
implementation 'org.avaje.jetty:avaje-jetty-runner:2.3.1'
// https://jarcasting.com/artifacts/org.avaje.jetty/avaje-jetty-runner/
implementation ("org.avaje.jetty:avaje-jetty-runner:2.3.1")
'org.avaje.jetty:avaje-jetty-runner:jar:2.3.1'
<dependency org="org.avaje.jetty" name="avaje-jetty-runner" rev="2.3.1">
  <artifact name="avaje-jetty-runner" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.avaje.jetty', module='avaje-jetty-runner', version='2.3.1')
)
libraryDependencies += "org.avaje.jetty" % "avaje-jetty-runner" % "2.3.1"
[org.avaje.jetty/avaje-jetty-runner "2.3.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.eclipse.jetty : jetty-webapp jar [9.3.11.v20160721]

provided (1)

Group / Artifact Type Version
org.eclipse.jetty.websocket : javax-websocket-server-impl jar [9.3.11.v20160721]

Project Modules

There are no modules declared in this project.

avaje-jetty-runner

  • avaje-jetty-runner : Maven Central : avaje-jetty-runner

Jetty webapp runner for a war file (aka runnable war) or expanded webapp (aka IDE development mode).

It is literally 3 classes (11k as a jar) and provides convenience for using Jetty to run standard war format webapps. Jetty comes with WebAppContext and this "Jetty runner" is fairly lightweight configuring an underlying jetty WebAppContext and server.

What it does

  • Configures the WebAppContext (port, context path, tmp directory, cookie handler etc)
  • Detects if WebSocket support is in the classpath and if so sets up WebSocket support
  • Sets up a shutdown hook
  • RunWar handles extract/expand war (by default not expanded)
  • RunWar handles runnable jar format (i.e. Spring boot loader war format)

Runnable wars with Spring boot loader

Spring boot loader provides both jar and war packaging with the associated class loader support. We can use this along with Jetty runner to create a runnable war.

  • Package a web application using Spring boot loader
  • Include appropriate Jetty dependencies (webapp + optional websocket support)
  • Use the Spring boot loader class loader
  • Jetty runner provides a main() method to configure and run a Jetty WebAppContext

Using JettyRun for development

JettyRun provides a run() method that launches Jetty. This by default expects an expanded webapp to located in the src/main/webapp directory.

The main benefit of using JettyRun to run the webapp via the IDE is that it will use the classpath from the IDE.

package example.main;

import org.avaje.jettyrunner.JettyRun;

/**
 * Run the webapp using Jetty. 
 * 
 * This uses the IDE classpath, debugger etc.
 */
public class RunJettyWebappInIDE {

  public static void main(String[] args) {
    
    
    JettyRun jettyRun = new JettyRun();
    jettyRun.setHttpPort(8090);                    // default to 8080
    jettyRun.setContextPath("/hello");             // defaults to "/"
    jettyRun.setResourceBase("src/main/webapp");   // defaults to "src/main/webapp"
    
    jettyRun.runServer();
  }
}
org.avaje.jetty

avaje

Versions

Version
2.3.1
2.2.1
2.1.2
2.1.1
1.2.2
1.2.1
1.1.0
1.0.1