As a Java/Jakarta EE developer, we can rely on the javax
standards to work on every certified application server in the same way. When it comes to managing the application server, every vendor has a different and proprietary API for managing its resources. To use a different application server you first have to get comfortable with its CLI and config files. Wouldn't be a Java EE application server cheat sheet perfect for a quick reference?
To provide you a faster learning curve for a new application server, I've created such a cheat sheet for every major Java/Jakarta EE application server (Payara, Open Liberty, WildFly and TomEE). With this cheat sheet, you will have a reference for starting/stopping the server, finding relevant logs files, getting general server information, customizing the server configuration, adding custom libraries, and creating a JDBC data source with PostgreSQL as an example.
You can download the PDF version of this Java EE & Jakarta EE application server cheat sheet here.
Payara (most is also valid for Glassfish)
Starting and stopping the server:
1 2 3 4 5 6 7 8 9 10 11 | # Starting on Windows - default domain is domain1 $PAYARA_HOME/bin/asadmin.bat start-domain [domain_name] # Starting on Mac & Linux $PAYARA_HOME/bin/asadmin start-domain [domain_name] # Stopping on Windows $PAYARA_HOME/bin/asadmin.bat stop-domain [domain_name] # Stopping on Max & Linux $PAYARA_HOME/bin/asadmin stop-domain [domain_name] |
- Server logs:
$PAYARA_HOME/glassfish/domains/[domain_name]/logs/server.log
- Important ports:
- 8080 – HTTP listener
- 8181 – HTTPS listener
- 4848 – HTTPS admin listener
- 9009 – Debug port
- Admin panel:
http://localhost:4848
- Central configuration file:
domain.xml
in$PAYARA_HOME/glassfish/domains/[domain_name]/config
- Embedded database:
H2
(default) andDerby
- Auto-deploy folder:
$PAYARA_HOME/glassfish/domains/[domain_name]/autodeploy
- Available domains per default: domain1 (default) & production
- Add custom libraries to the application server:
1 2 3 4 5 6 7 8 | # For Windows $PAYARA_HOME/bin/asadmin.bat add-library /path/to/download/your-jar.jar # For Mac & Linux $PAYARA_HOME/bin/asadmin add-library /path/to/download/your-jar.jar # e.g. adding PostgreSQL JDBC driver $PAYARA_HOME/bin/asadmin add-library /home/username/.m2/repository/org/postgresql/postgresql/42.2.5/postgresql-42.2.5.jar |
- Configure a new data source:
- Configure a JDBC connection pool (pick one):
- via admin panel: Resources -> JDBC -> JDBC Connection Pool -> New -> Follow the wizard
- via asadmin:
- Configure a JDBC connection pool (pick one):
1 2 3 4 5 6 7 | # For Windows $PAYARA_HOME/bin/asadmin.bat create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGPoolingDataSource --restype javax.sql.DataSource --property portNumber=5432:serverName=localhost:user=postgres:password=postgres:databaseName=postgres PostgresPool # For Mac & Linux $PAYARA_HOME/bin/asadmin create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGPoolingDataSource --restype javax.sql.DataSource --property portNumber=5432:serverName=localhost:user=postgres:password=postgres:databaseName=postgres PostgresPool |
-
-
- with adding an entry in
$PAYARA_HOME/glassfish/domains/[domain_name]/config/domain.xml
:
- with adding an entry in
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <domain> <resources> <jdbc-connection-pool name="PostgresPool" res-type="javax.sql.DataSource" datasource-classname="org.postgresql.ds.PGPoolingDataSource"> <property name="Url" value="jdbc:postgresql://localhost:5432/"/> <property name="Password" value="postgres"/> <property name="User" value="postgres"/> <property name="databaseName" value="postgres"/> <!-- far more can be configured for use in production --> </jdbc-connection-pool> </resources> </domain> |
-
- Create a JDBC resource (pick one):
- via admin panel: Resources -> JDBC -> JDBC Resouces -> New -> Follow the wizard
- with asadmin:
- Create a JDBC resource (pick one):
1 2 3 4 5 | # For Windows $PAYARA_HOME/bin/asadmin.bat create-jdbc-resource --connectionpoolid PostgresPool jdbc/postgres # For Mac & Linux $PAYARA_HOME/bin/asadmin create-jdbc-resource --connectionpoolid PostgresPool jdbc/postgres |
-
-
- via adding an entry in
$PAYARA_HOME/glassfish/domains/[domain_name]/config/domain.xml
:
- via adding an entry in
-
1 2 3 4 5 6 7 8 | <domain> <resources> <jdbc-resource pool-name="NameOfTheConnectionPool" jndi-name="jdbc/postgres"></jdbc-resource> <!-- e.g. <jdbc-resource pool-name="PostgresPool" jndi-name="jdbc/postgres"></jdbc-resource> --> </resources> </domain> |
- Official docker images
- Sample Docker image:
1 2 3 4 5 | FROM payara/server-full:latest COPY target/your-war.war $DEPLOY_DIR # docker build -t mypayaraapp . # docker run -p 8080:8080 -p 4848:4848 -d mypayaraapp |
- CDI implementation provider: Weld
- JAX-RS implementation provider: Jersey
- JPA implementation provider: EclipseLink
- JSF implementation provider: Mojarra
Open Liberty
Starting and stopping the server:
1 2 3 4 5 6 7 8 9 10 11 | # Starting on Windows - default server name is defaultServer $WLP_HOME/bin/server.bat start [server_name] # Starting on Mac & Linux $WLP_HOME/bin/server start [server_name] # Stopping on Windows $WLP_HOME/bin/server.bat stop [server_name] # Stopping on Mac & Linux $WLP_HOME/bin/server stop [server_name] |
- Server logs:
$WLP_HOME/usr/servers/[sever_name]/logs/console.log
and$WLP_HOME/usr/servers/[sever_name]/logs/messages.log
- Important ports:
- 9080– HTTP listener
- 9443 – HTTPS listener
- Admin panel: none
- Central configuration file:
server.xml
in$WLP_HOME/usr/servers/[sever_name]
(hot reloading of configuration is possible) - Embedded database: none,
Derby
can be configured like the following:- Download the
derby.jar
- Update the
server.xml
and reference to the downloaded.jar
file:
- Download the
1 2 3 4 5 6 7 8 9 10 11 | <server> <!-- other settings omitted --> <dataSource id="DefaultDataSource"> <jdbcDriver libraryRef="DERBY_JDBC_LIB" /> <properties.derby.embedded databaseName="test" createDatabase="create" /> </dataSource> <library id="DERBY_JDBC_LIB"> <file name="/home/user/derby/lib/derby.jar" /> </library> </server> |
- Auto-deploy folder:
$WLP_HOME/usr/servers/[sever_name]/dropins
- Available servers per default: defaultSever
- Add custom libraries to the application server:
- The following
<library>
elements are available for theserver.xml
:
- The following
1 2 3 4 5 | <library> <folder dir="..." /> <file name="..." /> <fileset dir="..." includes="*.jar" scanInterval="5s" /> </library> |
-
- either reference the library from your filesystem or place it in
${server.config.dir}/lib
(specific libs for the server e.g.$WLP_HOME/usr/servers/defaultServer/lib
) or${shared.config.dir}/lib/global
for global libs
- either reference the library from your filesystem or place it in
- Configure a new data source:
- Reference the JDBC driver within the
server.xml
and give it a unique name:
- Reference the JDBC driver within the
1 2 3 4 5 | <server> <library id="POSTGRES_JDBC_LIB"> <file name="/home/user/.m2/repository/org/postgresql/postgresql/42.2.5/postgresql-42.2.5.jar" /> </library> </server> |
-
- Create a new
<dataSource>
element within theserver.xml
and configure the access to the data source and JNDI name:
- Create a new
1 2 3 4 5 6 7 8 | <server> <dataSource id="postgres" jndiName="jdbc/postgres" type="javax.sql.DataSource"> <jdbcDriver javax.sql.DataSource="org.postgresql.ds.PGPoolingDataSource" libraryRef="POSTGRES_JDBC_LIB"/> <properties databaseName="postgres" serverName="localhost" password="postgres" portNumber="5432" user="postgres"/> </dataSource> </server> |
- Official docker images
- Sample Docker image:
1 2 3 4 5 6 | FROM open-liberty:kernel COPY server.xml /config/ COPY target/your-war.war /config/dropins # docker build -t myopenlibertyapp . # docker run -p 9080:9080 -p 9443:9443 -d myopenlibertyapp |
- CDI implementation provider: Weld
- JAX-RS implementation provider: ApacheCXF
- JPA implementation provider: EclipseLink (customizable via
server.xml
to use Hibernate) - JSF implementation provider: Apache MyFaces
WildFly
Starting and stopping the server:
1 2 3 4 5 6 7 8 9 10 11 | # Starting on Windows - standalone mode for running a single instance $WILDFLY_HOME/bin/standalone.bat # Starting on Mac & Linux $WILDFLY_HOME/bin/standalone.sh # Stopping on Windows $WILDFLY_HOME/bin/jboss-cli.bat --connect command=:shutdown # Stopping on Mac & Linux $WILDFLY_HOME/bin/jboss-cli.sh --connnect command=:shutdown |
- Server logs:
$WILDFLY_HOME/standalone/log/server.log
for running instandalone
mode - Important ports:
- 8080 – HTTP listener
- 8443 – HTTPS listener
- 9990 – Admin panel
- Admin panel:
http://localhost:9990
- To log in, you first have to create a user via:
1 2 3 4 5 | # Windows $WILDFLY_HOME/bin/addUser.bat user userPassword # Mac & Linux $WILDFLY_HOME/bin/addUser.sh user userPassword |
- Central configuration file:
standalone.xml
in$WILDFLY_HOME/standalone/configuration
- Embedded database:
H2
- Auto-deploy folder:
$WILDFLY_HOME/standalone/deployments
- Available server modes per default: standalone (single instance) and domain (cluster) mode
- Add custom libraries to the application server: Follow the steps as described for the JDBC driver and create a module
- Configure a new data source:
- Create a new folder
org/postgresql/main
within$WILDFLY_HOME/modules
- Copy the JDBC driver (e.g.
postgresql-42.2.5.jar
) to this folder - Create a
module.xml
file within this folder:
- Create a new folder
1 2 3 4 5 6 7 8 9 10 | <?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="org.postgresql"> <resources> <resource-root path="postgresql-42.2.5.jar" /> </resources> <dependencies> <module name="javax.api" /> <module name="javax.transaction.api" /> </dependencies> </module> |
-
- Connect to your running WildFly with
$WILDFLY_HOME/bin/jboss-cli.bat --connect
or$WILDFLY_HOME/bin/jboss-cli.sh --connect
- Execute:
- Connect to your running WildFly with
1 2 3 4 5 | # First create the new module for the JDBC driver /subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql, driver-module-name=org.postgresql, driver-class-name=org.postgresql.Driver, driver-datasource-class-name=org.postgresql.ds.PGPoolingDataSource) # Create a data source /subsystem=datasources/data-source=PostgresDS:add(jndi-name=java:jboss/datasources/postgres, driver-name=postgresql, connection-url=jdbc:postgresl://localhost:5432/postgres, user-name=postgres, password=postgres) |
- Official docker images
- Sample docker image:
1 2 3 4 5 | FROM jboss/wildfly:16.0.0.Final COPY target/your-war.war /opt/jboss/wildfly/standalone/deployments/ # docker build -t mywildflyapp . # docker run -p 8080:8080 -p 8443:8443 -p 9990:9990 -d mywildflyapp |
- CDI implementation provider: Weld
- JAX-RS implementation provider: RESTEasy
- JPA implementation provider: Hibernate
- JSF implementation provider: Mojarra
TomEE
Starting and stopping the server:
1 2 3 4 5 6 7 8 9 10 11 | # Starting on Windows $CATALINA_HOME/bin/catalina.bat start # Starting on Mac & Linux $CATALINA_HOME/bin/catalina.sh start # Stopping on Windows $CATALINA_HOME/bin/catalina.bat stop # Stopping on Mac & Linux $CATALINA_HOME/bin/catalina.sh stop |
- Server logs:
$CATALINA_HOME/logs/catalina.DATE.log
- Important ports:
- 8080 – HTTP listener
- 8443 – HTTPS listener
- Admin panel:
http://localhost:8080/manager/html
- To log in, you first have to create a user in
$CATALINA_HOME/conf/tomcat-users.xml
:
- To log in, you first have to create a user in
1 2 3 4 5 6 7 8 | <?xml version="1.0" encoding="UTF-8"?> <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <role rolename="tomee-admin" /> <user username="tomee" password="tomee" roles="tomee-admin,manager-gui" /> </tomcat-users> |
- Central configuration file:
server.xml
,context.xml
andtomee.xml
in$CATALINA_HOME/config
- Embedded database:
HSQL
- Auto-deploy folder:
$CATALINA_HOME/webapps
- Add custom libraries to the application server: Copy the library to
$CATALINA_HOME/lib
- Configure a new data source:
- Copy the JDBC driver (e.g.
postgresql-42.2.5.jar
) to$CATALINA_HOME/lib
- Add the following config to
$CATALINA_HOME/config/tomee.xml
- Copy the JDBC driver (e.g.
1 2 3 4 5 6 7 8 | <tomee> <Resource id="jdbc/postgres" type="javax.sql.DataSource"> jdbcDriver org.postgresql.Driver jdbcUrl jdbc:postgresql://127.0.0.1:5432/postgres userName postgres password postgres </Resource> </tomee> |
- Official docker images
- Sample Docker image:
1 2 3 4 | FROM tomee:8-jre-8.0.0-M2-plume COPY target/your-war.war /usr/local/tomee/webapps/ # docker build -t mytomeeapp . # docker run -p 8080:8080 -p 8443:8443 -d mytomeeapp |
- CDI implementation provider: Apache OpenWebBeans
- JAX-RS implementation provider: Apache CXF
- JPA implementation provider: EclipseLink
- JSF implementation provider: Mojarra
You can download the PDF version of this Java EE & Jakarta EE application server cheat sheet here.