A Maven plugin for managing Embedded GlassFish server instances during the build lifecycle.
Run your project's main artifact on Embedded GlassFish directly from command line without modifying your pom.xml
:
mvn org.glassfish.embedded:embedded-glassfish-maven-plugin:7.1-SNAPSHOT:run -Dglassfish.version=7.0.25
Or add the plugin to your pom.xml
:
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>embedded-glassfish-maven-plugin</artifactId>
<version>7.1-SNAPSHOT</version>
<configuration>
<glassfish.version>7.0.25</glassfish.version>
</configuration>
</plugin>
Start the server with your application and wait until it stops:
mvn embedded-glassfish:run
- JDK 11 or higher
- Maven 3.6.3 or higher
Start server in background:
mvn embedded-glassfish:start
Deploy application:
mvn embedded-glassfish:deploy
Stop server:
mvn embedded-glassfish:stop
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>embedded-glassfish-maven-plugin</artifactId>
<version>7.1-SNAPSHOT</version>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>undeploy</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Goal | Description | Default Phase |
---|---|---|
start |
Starts an Embedded GlassFish server | pre-integration-test |
stop |
Stops the Embedded GlassFish server | post-integration-test |
deploy |
Deploys an application to the server | pre-integration-test |
undeploy |
Undeploys an application from the server | post-integration-test |
run |
Starts server and keeps it running | none |
admin |
Executes admin commands | none |
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>embedded-glassfish-maven-plugin</artifactId>
<version>7.1-SNAPSHOT</version>
<configuration>
<port>8080</port>
<app>${project.build.directory}/${project.build.finalName}.war</app>
</configuration>
</plugin>
port
- HTTP port number for the server (default: 8080)app
- Path to the application artifact to deploy (default: main artifact)
The plugin automatically detects and deploys your project's main artifact without requiring explicit configuration:
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>embedded-glassfish-maven-plugin</artifactId>
<version>7.1-SNAPSHOT</version>
<configuration>
<!-- Main artifact automatically deployed if no <app> parameter specified -->
</configuration>
</plugin>
Note: Currently assumes WAR packaging. For other artifact types, specify the app
parameter explicitly.
Execute administrative commands on the running server:
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>embedded-glassfish-maven-plugin</artifactId>
<version>7.1-SNAPSHOT</version>
<configuration>
<commands>
<command>set configs.config.server-config.network-config.protocols.protocol.http-listener.http.websockets-support-enabled=true</command>
<command>create-jdbc-resource --connectionpoolid mypool jdbc/myresource</command>
</commands>
</configuration>
</plugin>
Command line usage:
mvn embedded-glassfish:admin -Dcommands="set server.monitoring-service.module-monitoring-levels.web-container=HIGH"
configFile
- Custom domain configuration fileglassfish.version
- GlassFish version to useport
- HTTP port number (default: 8080)ports
- Map of port configurationsserverID
- Server identifier (default: "maven")
app
- Path to application artifact to deploy (defaults to${project.build.directory}/${project.build.finalName}.war
)contextRoot
- Application context rootname
- Application name (default: "myapp")
bootstrapProperties
- Bootstrap propertiesglassfishProperties
- GlassFish server propertiesinstanceRoot
- Server instance root directory
Starts an Embedded GlassFish server with the configured parameters.
Default Phase: pre-integration-test
Configuration:
- Uses all server configuration parameters (serverID, port, glassfishProperties, etc.)
Example:
mvn embedded-glassfish:start
Stops the Embedded GlassFish server and cleans up resources.
Default Phase: post-integration-test
Configuration:
serverID
- Server identifier to stop (default: "maven")
Example:
mvn embedded-glassfish:stop
Deploys an application to the running Embedded GlassFish server.
Default Phase: pre-integration-test
Configuration:
app
- Application path (auto-detects if not specified)name
- Application name (default: "myapp")contextRoot
- Web application context rootdeploymentParams
- Additional deployment parameters
Example:
mvn embedded-glassfish:deploy -Dapp=target/myapp.war
Undeploys an application from the Embedded GlassFish server.
Default Phase: post-integration-test
Configuration:
name
- Application name to undeploy (default: "myapp")undeploymentParams
- Additional undeployment parameters
Example:
mvn embedded-glassfish:undeploy -Dname=myapp
Starts the server, deploys applications, and runs interactively. Allows redeployment by pressing Enter or exit by typing 'X'.
Default Phase: none (manual execution)
Configuration:
- Combines all server and deployment configurations
- Executes all configured admin and deploy goals
Example:
mvn embedded-glassfish:run
Executes administrative commands on the running server.
Default Phase: pre-integration-test
Configuration:
commands
- Array of admin commands to execute
Example:
mvn embedded-glassfish:admin -Dcommands="create-jdbc-resource --connectionpoolid mypool jdbc/myresource"
Eclipse Public License v. 2.0