Chapter 5. Offline Mode
You can run the Apache Karaf container in offline mode (that is, without an Internet connection). But if you are planning to deploy custom applications to the container, it might be necessary to download additional dependencies to a local Maven repository before you can run the container in offline mode with these applications.
To run the Apache Karaf container in offline mode, it is necessary to distinguish between the following kinds of dependency:
- Runtime dependencies — the dependencies required to run the Apache Karaf container, in its default configuration.
- Build-time dependencies — the dependencies required to build a custom application (which might include third-party libraries).
Here is a summary of what can be done in offline mode and what needs to be done in online mode (with an Internet connection):
-
Running the Apache Karaf container in its default configuration — is supported in offline mode. The default configuration of the Apache Karaf container is specified by the
featuresBoot
property in theetc/org.apache.karaf.features.cfg
file. The requisite dependencies are all provided in thesystem/
sub-directory of the installation. -
Installing additional features — is, in general, not supported in offline mode. In principle, you can use the
features:install
command to install any of the features from the standard feature repositories (as specified by thefeaturesRepositories
property in theetc/org.apache.karaf.features.cfg
file), but the majority of these features must be downloaded from the Internet and are thus not supported in offline mode. - Deploying custom applications — is, in general, not supported in offline mode. There may be some cases where an application with a minimal set of build-time dependencies is deployable offline, but in general, custom applications would have third-party dependencies that require an Internet connection (so that JAR files can be downloaded by Apache Maven).
If you do need to deploy an application with dependencies that are not available offline, you can use the Maven dependency plug-in to download the application’s dependencies into a Maven offline repository. This customized Maven offline repository can then be distributed internally to any machines that do not have an Internet connection.
5.1. Download repository for Maven project
From the project directory that contains the pom.xml
file, run the following Maven command:
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.0:go-offline -Dmaven.repo.local=/tmp/foo
All the Maven dependencies and plug-ins required to build the project will be downloaded to the /tmp/foo
directory.
5.2. Enable offline mode
To enable offline mode you must edit etc/org.ops4j.pax.url.mvn.cfg
. Find the setting org.ops4j.pax.url.mvn.offline
and replace the default false
with true
.
## # If set to true, no remote repository will be accessed when resolving artifacts # org.ops4j.pax.url.mvn.offline = true