/jakartaee9-servlet-starter-boilerplate

A Jakarta EE starter project boilerplate for Jakarta Servlet 5.0 (aligned with Jakarta EE 9) Container

Primary LanguageJavaApache License 2.0Apache-2.0

jakartaee9-servlet-starter-boilerplate

Compile and build it-tomcat it-jetty Quality Gate Status Coverage

Yeah, this is another starter boilerplate project for Jakarta EE (esp. Servlet/Java Web) developers.

This repository is a lightweight variant of the original Jakarta EE 9 starter boilerplate which allows you to run applications on a Servlet 5.0 compatible container, such as Apache Tomcat, Eclipse Jetty, JBoss Undertow.

Currently, the following features are added.

  • Jakarta REST 3.0(Jersey 3.0)
  • CDI 3.0 (Weld 4.0)
  • Jakarta Server Faces 3.0(Mojarra 3.0)
  • And transitive dependencies of above features, incuding Jakarta EL, Jarkarta Json Processing, Jakarta Json Binding, Jakarta Validation(Hibernate Validator), etc.

Nowadays the most popular Servlet containers, such as Apache Tomcat, Eclipse Jetty, etc. have built-in Jakarta Servlet, Jakarta Server Pages, JSTL, Jakarta EL and Jakarta WebSocket supports.

For full-fledged features support of Jakarta EE 9, please go to hantsy/jakartaee9-starter-boilerplate.

Apache Tomcat 10

Run the following command to run the application on Tomcat 10.

mvn clean package cargo:run

Eclipse Jetty 11

The new jetty-maven-plugin reorganizes the former run-fork goal and provides 3 modes to run a Jetty server.

  • EMBEDDED
  • FORKED
  • EXTERNAL

The default mode is EMBEDDED similar to the simplest jetty:run goal in the previous version.

The FORKED mode uses a forked thread to run the application.

The EXTERNAL mode runs the application on an external Jetty server.

This sample project provides configurations for EMBEDED and EXTERNAL mode.

There is a jetty-embed profile for EMBEDED mode and a jetty-external profile for EXTERNAL mode.

To run the application on EMBEDED mode, run the following command.

mvn clean jetty:run -Pjetty-embed

To run the application on EXTERNAL mode, firstly download a copy of the latest Eclipse Jetty 11 and set an environment variable JETTY_HOME to the location of the Jetty distribution.

Then run the following command.

mvn clean jetty:run -Pjetty-external

Testing

The testing codes write with JUnit and Arquillian.

Run the following command to execute tests against a Tomcat 10 Embedded adapter.

mvn clean verify -Parq-tomcat-embedded

Alternatively, run the following command to execute tests against a Jetty 11 Embedded adapter.

mvn clean verify -Parq-jetty-embedded

There is another arq-weld Maven profile with which you can run tests on a Weld embedded adapter.

mvn clean verify -Parq-weld

Note: The arq-weld is only used to test CDI components.

Resources