server package command

The 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 container:

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

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 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 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/wlp/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

Options for the server package command
OptionDescription

--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 documentation for operating system names. 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. By default, the root folder is /wlp.

Exit codes

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

Exit codes for the server package command
CodeExplanation

0

This code indicates successful completion of the requested operation.

1

This code indicates invocation of a redundant operation. For example, starting a started server or stopping a stopped server. This code might also be returned by JVM if invalid Java options are used.

2

This code indicates that the server does not exist.

3

This code 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 that are 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.