Get Started
Dev Mode
server:dev runs your Jakarta EE application on Payara or GlassFish, then reloads the browser as you change the code, recompiling, reloading the application and running your tests when the code changes. No server scripts to write.
One command takes a Jakarta EE project from source to a running application, and keeps it current while you work:
./mvnw package server:dev
It starts Payara or GlassFish, deploys your application and opens it in the browser.
Then it watches src/main. When you save a change, it reloads the page. If the code changed, it first recompiles and reloads the application, and then runs your tests.
There are no server scripts, IDE plugins or deployment descriptors to write.
server:dev comes from the Container Deploy Plugin.
The payara-pom and glassfish-pom parent POMs include it,
so every project created by the JStarter already has it.
|
Tip
|
With mvnd installed, mvnd package server:dev starts even faster.
See mvnd and a running server before you use it to start the server.
|
How it compares
The JavaScript dev server experience, for Jakarta EE
Front-end developers take live reload for granted. Dev servers such as Vite
watch the source files and tell the open page to update over a WebSocket, and they show the error when a build breaks.
server:dev brings the same loop to Jakarta EE: save a file, and the page in the browser is already up to date.
If the build or the tests fail, the page tells you so instead.
Vite can swap a single module without reloading the page. server:dev reloads the whole page,
since the server-side code may have changed.
No manual browser refresh, unlike quarkus:dev
Quarkus dev mode recompiles your code when you refresh the browser:
the Quarkus guide says to edit, save, and refresh.
server:dev refreshes the browser for you, and runs your tests on every change.
That brings the Quarkus loop, and then some, to standard Jakarta EE applications on Payara and GlassFish.
For Quarkus projects, keep using ./mvnw quarkus:dev.
How it works
The first run
-
If the server isn’t running, the plugin unpacks it from Maven Central into
target/dependencyand starts its domain. The server version comes from the parent POM, so there is nothing to download or install by hand. -
It builds your application as an exploded WAR and deploys it.
-
It opens the application in your browser.
-
It watches
src/mainfor changes.
If the application is already deployed, for example from an earlier run, server:dev reuses that deployment.
When you save a change
-
Web resources such as XHTML, CSS and JavaScript: the plugin copies them into the exploded WAR and reloads the page. The application isn’t reloaded: in development mode, Jakarta Faces picks up the changed files by itself.
-
Java and other source code: the plugin recompiles, reloads the application on the server, reloads the page and then runs your unit tests. The application is reloaded only when the code changes.
Pressing Ctrl+C stops watching. The server keeps running, so the next server:dev starts in milliseconds.
Use ./mvnw server:stop to stop it.
|
Warning
|
If mvnd started the server, pressing Ctrl+C stops the server too.
A server started by ./mvnw or mvn keeps running.
If you want the server to stay up between sessions, start it with ./mvnw (for example ./mvnw server:start),
not with mvnd. Once it’s running, mvnd package server:dev is safe to use and to stop.
|
Live reload in the browser
Live reload works in Jakarta Faces applications that use the Flow Logix Jakarta Faces integration. In development mode, Flow Logix adds a small script to each page, which keeps a WebSocket open to the server.
-
After a change, the page reloads itself.
-
If compilation or deployment fails, the web page shows an error message instead of reloading.
-
If the tests fail, the web page shows a test failure message. The details are in the Maven output.
-
If the server restarts, the page reconnects by itself.
Flow Logix also turns off Facelets caching in development mode, so reloading always shows the latest page.
|
Note
|
The LiveReload helper accepts WebSocket connections only from the same origin as the page, and doesn’t require a login. It is meant for development machines. Protect shared servers with network or proxy access controls. |
Dependencies on the server
By default, server:dev deploys a regular WAR, with its dependencies in WEB-INF/lib.
|
Note
|
lib/warlibs is currently supported on Payara only.
|
To deploy and reload faster, you can build skinny WARs with -Dskinny.war,
and keep the dependencies in the server’s lib/warlibs directory instead.
The server then loads them once globally, so keep them up to date with the project:
./mvnw package server:deps server:restart server:dev
Run this whenever the dependencies change, or when the server log reports a missing class.
server:deps replaces everything in lib/warlibs, so it affects every application on that server.
To ignore lib/warlibs for one project, add -Dserver.warlibs=false.
To redeploy an application the server says is already deployed, add -Dserver.force.
Goals
server:dev covers everyday work. The other goals give you finer control:
| Goal | What it does |
|---|---|
|
Starts the server if needed, deploys, opens the browser, then reloads the page on every change. When the code changes, it also recompiles, reloads the application and runs the tests. |
|
Like |
|
Deploys the application. |
|
Undeploys the application. |
|
Reloads the application on the server. |
|
Copies the project’s dependencies to the server’s |
|
Removes all dependencies from the server’s |
|
Unpacks the application server. |
|
Starts the application server. |
|
Stops the application server. |
|
Restarts the application server. |
|
Shows information about the server and the application. |
Options
Set options on the command line with -D, or as properties in your pom.xml.
| Property | Description | Default |
|---|---|---|
|
The server’s administration URL |
|
|
The HTTP port the application runs on |
|
|
Deploy even if the server says the application is already deployed |
|
|
Use the libraries in the server’s |
|
|
Enable availability (session replication) for the deployed application |
|
|
Keep the application’s state on redeploy, as an alternative to availability |
|
|
Delay before reacting to a file change, in milliseconds |
|
|
How many times to send a test failure to the browser. |
|
|
The application’s name on the server, for |
The project’s final name |
The plugin’s README lists every option.
Use it without the Flow Logix parent POMs
The plugin works with any Payara or GlassFish project. Add it to your pom.xml:
<build>
<plugins>
<plugin>
<groupId>com.flowlogix.plugins</groupId>
<artifactId>container-deploy-plugin</artifactId>
<version><!-- latest version --></version>
</plugin>
</plugins>
</build>
Without the server parent POMs, the plugin can’t download or start the server for you,
because they configure the server’s version, download and domain.
Start Payara or GlassFish yourself, and the plugin connects to it at server.adminUrl.