server package command

Packages an Open Liberty server, its resources, and applications in a compressed file that you can store, distribute, or deploy to a different location.

You can select the parts of your Open Liberty server installation to package. You can package an application with a full or a minimal Open Liberty runtime environment, or without an Open Liberty runtime environment so that the application can be deployed on an existing Open Liberty installation.

Usage examples

Generate a ZIP file named myserver.zip that includes all files in the Open Liberty installation directory with the myserver server files:

server package myserver --include=all

Generate a ZIP file named package_myserver.zip that has only the myserver server files for deployment on an existing Open Liberty runtime installation, such as in a Docker container:

server package myserver --archive=package_myserver.zip --include=usr

Generate a ZIP file, myserver.zip, with the root folder named mywlp instead of wlp:

server package myserver --server-root="mywlp"

Package the Open Liberty runtime into a ZIP file, wlp.zip, that does not include the usr directory, so it has no servers or applications:

server package --include=wlp

Package the Open Liberty runtime into a ZIP file named myPackage.zip and put it in the C:\temp directory:

server package --include=wlp --archive=C:\temp\myPackage.zip

Generate a runnable JAR file of the myserver server named myserver.jar:

server package myserver --include=runnable

Generate a minimal runnable JAR file of the myserver server named package_myserver.jar to the C:\temp directory:

server package myserver --archive="C:\temp\package_myserver.jar" --include=minify,runnable

Generate a TAR file of the myserver server named package_myserver.tar to the C:\temp directory:

server package myserver --archive="C:\temp\package_myserver.tar"

Package a server that supports only Linux:

server package myserver --archive=linux.zip --include=minify --os=Linux

Package a server with Linux support, but no Windows support:

server package myserver --archive=small.zip --include=minify --os=Linux,-Win32

Syntax

Run the command from the path_to_liberty/bin directory. To package a server, stop the server before running the command.

server package serverName [options]
serverName

The name of the server to run the command against. A server name is needed to package a server. A server name is not needed to package the Open Liberty runtime.

options

One or more optional parameters.

Options

Option Description

--archive="package_file_name.zip"

Specifies a target file for the package operation. This path can be either a relative path, which is relative to the installation root directory of Open Liberty, or an absolute path. The default archive target is a ZIP file with the server name, which is stored in the installation root directory. Use quotation marks if the value contains spaces. ZIP, JAR, TAR, and TAR GZ are all valid archive file options.

If you specify a .jar extension for your archive file name, the command creates a JAR file. See also the --include=runnable option.

If you do not specify a valid package name or target location, the command creates the wlp.zip runtime archive in the ${WLP_OUTPUT_DIR} location, which is the ${wlp.install.dir}/usr/servers directory by default. The target location must exist before running the command. If the target location is C:\temp, the C:\temp directory must exist and have write permission for the command to write the archive to the C:\temp directory.

The resulting file is created by using UTF-8 encoding for entry names, so the tool that you use to open the file must be able to use UTF-8 encoding for entry names. The jar command in a Java SDK uses this format.

--include=all

Packages all the files in the Open Liberty installation directory. If the ${WLP_USER_DIR} and ${WLP_OUTPUT_DIR} are defined in the server.env file, then the files under them are packaged.

--include=usr

Packages the files in the ${WLP_USER_DIR} directory.

--include=wlp

Packages the files in the wlp directory but does not contain the usr directory.

--include=minify

Packages only the parts of the runtime environment and files in the ${WLP_USER_DIR} directory that are required to run the server, which minimizes the size of the resulting archive.

The parts of the runtime environment that are retained by the minify operation depend on the features that are configured in the server that you are packaging. Only those features that are required to run the server are retained, and the remaining features are removed. Therefore, you cannot later enable a feature that has been removed. For example, if only the servlet-3.0 feature is retained, you cannot later enable the jpa-2.0 feature.

You can repeat the minify operation to further reduce the size of the archive if the configuration is changed. There is, however, no reverse operation for the minify operation, so if you later require one or more features that have been removed, you must begin again with a complete Open Liberty server.

While the minify operation is running, the server is temporarily started, and you see the associated messages. For this reason, you cannot use the --include=minify option with a server that is not able to be started, but you can package it with the --include=all or --include=usr options.

--include=runnable

Use only with the --archive="package_file_name.jar" option. Packages an executable JAR file from which you can start an Open Liberty server by running the JAR file. See Runnable JAR files.

--include=minify,runnable and --include=all,runnable are also valid options. The runnable and all,runnable values are equivalent.

--os=os_value,os_value,…​

Use only with the --include=minify option. Specifies the operating systems that you want the packaged server to support. Supply a comma-separated list. The default value is any, indicating that the server is to be deployable to any operating system supported by the source.

To specify that an operating system is not to be supported, prefix it with a minus sign (-). For a list of operating system values, refer to the OSGi Alliance website. If you exclude an operating system, you cannot later include it if you repeat the minify operation on the archive.

--server-root="root server folder in archive"

Specifies the root server folder name in the archive file.

Exit codes

The following exit codes are available for the server package command and the equivalent executable JAR file ws-server.jar:

0

OK. 0 indicates successful completion of the requested operation.

1

1 indicates that the JVM options that were used are not valid.

2

2 indicates that the server does not exist.

3

3 indicates that an unsupported action was called on a running server. For example, the server is running when the package action is called.

>=20

Exit codes greater than or equal to 20 indicate that an error occurred while performing the request. Messages are printed and captured in log files with more information about the error.