此内容没有您所选择的语言版本。

Chapter 3. Karaf Migration


This section covers the changes in the Karaf version from 2.x to 4.x.

3.1. Migrating application code

Applications will need to be recompiled to align with the new versions provided. Use the Maven Bill of Materials (BOM) file to migrate Maven dependencies to the new versions and see also Component Details.

3.2. Karaf Console Commands

The console commands have been renamed in Apache Karaf 4.x and differ from what they are in 2.x. The purpose is to standardize the naming convention.

Note

All of the admin:* and instance:* commands (for managing child Karaf containers) are deprecated in Fuse 7.0 and will be removed in a future release. If you need to deploy multiple instances of a Karaf container on a single host, the recommended approach is to use OpenShift.

The following table lists the old commands and the new commands:

Expand
Table 3.1. Karaf console commands
Apache karaf 2.xApache karaf 4.x

dev:create-dump

dev:dump-create

features:add-url

feature:repo-add

features:chooseurl

feature:repo-add

features:info

feature:info

features:install

feature:install

features:listVersions

feature:version-list

features:list

feature:list

features:listRepositories

feature:repo-list

features:listUrl

feature:repo-list

features:refreshUrl

feature:repo-refresh

features:removeRepository

feature:repo-remove

features:removeUrl

feature:repo-remove

features:uninstall

feature:uninstall

jaas:pending

jaas:pending-list

jaas:realms

jaas:realm-list

jaas:users

jaas:user-list

jaas:manage

jaas:realm-manage

jaas:roleadd

jaas:role-add

jaas:roledel

jaas:role-delete

jaas:useradd

jaas:user-add

jaas:userdel

jaas:user-delete

config:propappend

config:property-append

config:propdel

config:property-delete

config:proplist

config:property-list

config:propset

config:property-set

dev:dynamic-import

bundle:dynamic-import

dev:framework

system:framework

dev:print-stack-traces

shell:stack-traces-print

dev:restart

system:shutdown

dev:show-tree

bundle:tree-show

dev:system-property

system:property

dev:wait-for-service

service:wait

dev:watch

bundle:watch

log:display-exception

log:exception-display

obr:addUrl

obr:url-add

obr:listUrl

obr:url-list

obr:refreshUrl

obr:url-refresh

obr:removeUrl

obr:url-remove

osgi:bundle-level

bundle:start-level

osgi:classes

bundle:classes

osgi:find-class

bundle:find-class

osgi:headers

bundle:headers

osgi:info

bundle:info

osgi:install

bundle:install

osgi:bundle-services

bundle:services

osgi:list

bundle:list

osgi:ls

service:list

osgi:name

system:name

osgi:refresh

bundle:refresh

osgi:resolve

bundle:resolve

osgi:restart

bundle:restart

osgi:shutdown

system:shutdown

osgi:start

bundle:start

osgi:start-level

bundle:start-level

osgi:stop

bundle:stop

osgi:uninstall

bundle:uninstall

osgi:update

bundle:update

osgi:version

system:version

packages:exports

package:exports

packages:imports

package:imports

Note

Fuse 7.0 defines aliases for the Karaf 2.x commands. So you can continue using the old commands.

3.3. JMX Object Names in Karaf 4.x

The JMX MBeans object names are renamed and the operations are dispatched in new MBeans.

The table below lists the old JMX MBeans object names and the respective new object names.

Expand
Table 3.2. JMX object names
Apache Karaf 2.xApache Karaf 4.x

org.apache.karaf:type=bundles,name=*

org.apache.karaf:type=bundle,name=*

org.apache.karaf:type=config,name=*

org.apache.karaf:type=config,name=*

org.apache.karaf:type=dev,name=*

org.apache.karaf:type=system,name=*

org;apache.karaf:type=log,name=*

org.apache.karaf:type=log,name=*

org.apache.karaf:type=obr,name=*

org.apache.karaf:type=obr,name=*

org.apache.karaf:type=packages,name=*

org.apache.karaf:type=package,name=*

org.apache.karaf:type=services,name=*

org.apache.karaf:type=service,name=*

org.apache.karaf:type=system,name=*

org.apache.karaf:type=system,name=*

org.apache.karaf:type=web,name=*

org.apache.karaf:type=web,name=*

3.4. Karaf Migration Changes

This section covers the changes in Karaf 2.x to Karaf 3.x.

3.4.1. Migrating from Karaf 2.x to Karaf 3.x

The changes to Apache Karaf that must be considered before upgrading from versions 2.x to 3.x are:

  • The files in the different Apache Karaf folders have changed, and the merge/diff is very large so it is advisable to start a new Apache Karaf 3.x container rather than overriding the folders from an Apache Karaf 2.x container.
  • The future Apache Karaf versions will introduce the concept of Karaf Profiles to simplify the update process.
  • WebApplications using the WebApp-Context headers in the MANIFEST are no longer supported.
  • Apache Karaf now supports the OSGi standard Web-ContextPath header in the MANIFEST.
  • Apache Karaf 3.0.x is fully supported by OPS4J Pax Exam.

3.4.2. Migrating from Karaf 3.x to Karaf 4.x

The changes to Karaf that must be considered before upgrading from Karaf 2.x to Karaf 3.x.

  • Karaf 4.x supports Java8.
  • If you upgrade an existing Karaf container, make a note to update the lib and system folders. For the etc folder, a diff is required.
  • Karaf 4.x has a new Feature Resolver. The purpose is to simplify the features installation and lifecycle. The new resolver now checks the feature requirements defined in the features XML, and check which bundles provides the capabilities to satisfy these requirements. It allows Karaf to automatically install bundles required by features. This feature is not enabled in Karaf 3.x.

3.5. New Commands in Karaf 4.x

Expand
Table 3.3. Apache Karaf 4.x commands
Apache Karaf 4.x

feature:requirement-list

feature:requirement-add

feature:requirement-remove

feature:regions

feature:start

feature:stop

jaas:group-create

jaas:group-add

jaas:group-delete

jaas:group-list

jaas:group-role-add

jaas:group-role-delete

jaas:su

jaas:sudo

shell:edit

shell:env

shell:less

shell:stack-traces-print

shell:threads

shell:while

log:list

bundle:capabilities

bundle:diag

bundle:id

bundle:load-test

bundle:requirements

bundle:resolve

system:name

  • In development environment you can use the blueprint definition as used in Karaf 2.x and 3.x with the corresponding annotations.
  • In Karaf 4.x, you can use DS and new annotations and avoid the usage of a blueprint XML. The new annotations are: @Service, @Completion, @Parsing, @Reference. You can define the command directly in the command class.
  • Karaf 4.x provides the karaf-services-maven-plugin in org.apache.karaf.tooling Maven groupId to simplify the generation of the code and OSGi headers.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat