Code Monkey home page Code Monkey logo

embedded-jetty-webapp's Introduction

Embedded Jetty web application

This project shows how to build a WAR-less Java web application with Jetty.

Only a single JVM is required to start the web app. No web container or JEE server is required.

Instead of building a war file, an auto-executable JAR file is built with Maven (ie. jetty-webapp-1.0.0-SNAPSHOT.jar)

This JAR contains all resources required by a web application: web.xml, index.jsp, images, js, css... The JettyServer class provides both a start and a stop method. Its main method starts the server. To stop it, you may use the Stop class.

Thanks to the Application Assembler Maven Plugin a start.sh and a stop.sh script are available.

All JAR dependencies are available in a lib\ sub-directory.

Try it

Download the code with git: git clone git://github.com/arey/embedded-jetty-webapp.git

Build and package the web application

cd embedded-jetty-webapp
mvn clean install

Start the web application

target/appassembler/bin/start.sh &

Stop the web application

target/appassembler/bin/stop.sh

Browse to http://localhost:8080/HelloWorld

Web port could be changed at startup:

target/appassembler/bin/start.sh 80 8090 &

Another possibility is to build a JAR that include all its dependencies (web app, jetty dependencies, logger, spring ...) :

mvn clean install -Pfatjar
java -jar target/jetty-webapp-1.0.0-SNAPSHOT-jar-with-dependencies.jar
java -cp target/jetty-webapp-1.0.0-SNAPSHOT-jar-with-dependencies.jar com.javaetmoi.jetty.Stop

Configuration rules

Compared to the Maven Standard Directory Layout of a WAR, the web application sources is not put into the src/main/webapp but into the src/main/resources/webapp. Thus the webapp resources are copied into the JAR in a webapp/ sub-directory.

Credits

embedded-jetty-webapp's People

Contributors

arey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.