Karaf assembly omits extra system packages ( javax.annotation two dependency chains)

Description

An occasional (race condition) Karaf assembly causes missing javax.annotation lines in the generated config.properties. This results in a dual dependency chain error when Opencast modules are loaded at startup.

Workaround: Rebuild the assembly again and check the generated config.properties for the missing lines.

Long Term: Karaf 4.2 has a different assembly strategy and may avoid this issue (OC currently on Karaf 4.0.10). KARAF-4996 appears to track this issue.

The error from the logs (message-broker-api is the first to load with the dependency on javax.annotation). This causes modules with a dependency on message-broker to not load.

One can provoke the error on the worker or the presentation node when the following lines are deleted in the correct config.properties.

Missing extra system packages from Karaf assembled etc/config.properties file:

The 7 javax.annotation-api class dependencies in Opencast modules (another project in github implemented a different Null check class to avoid the annotation-api all together because of this issue).

I believe this ticket tracks the issue: https://issues.apache.org/jira/browse/KARAF-4996.

KARAF-4996 was thought to be solved in Karaf 4.1.1, but the ticket has been re-opened. An older ticket partially solved the original issue and is probably related to the current issue: https://issues.apache.org/jira/browse/KARAF-3722. The karaf tooling is reworked in Karaf 4.2.0 and may avoid race conditions in building the "org.osgi.framework.system.packages.extra" listing in the generated config.properties.

Activity

Show:
Karen Dolan
May 18, 2018, 12:21 PM
Edited

The 3 pain points for annotation-api in the Karaf assembly:

pax-web-features-4.3.4-features.xml <bundle dependency="true" start-level="30">mvn:javax.annotation/javax.annotation-api/1.2</bundle>

apache-cxf-3.1.12-features.xml: <bundle start-level="10">mvn:javax.annotation/javax.annotation-api/1.2</bundle>

assemblies/pom.xml <library>mvn:javax.annotation/javax.annotation-api/1.2;type:=endorsed;export:=true</library>

1. Why annotations-api was added to Karaf features:
https://issues.apache.org/jira/browse/KARAF-3722

2. Where the dependency=true when into CXF
https://github.com/apache/cxf/commit/e2ec1c2a2d7cab8d8603b0448bc238fa2ebc45d3

3. When annotations-api went into:ops4j/org.ops4j.pax.web without a dependency=true
https://github.com/ops4j/org.ops4j.pax.web/commit/0b3590b1480a8b09b51159af7bd4733e161eedb2

Karen Dolan
May 18, 2018, 12:42 PM
Edited

The Karaf assembly issue might be more noticeable now because the javax.ws.rs 2.0.1 upgrade (https://github.com/opencast/opencast/commit/518c001e0a581daff2e898d8b94ddf1e9839b1d0) requires javax.annotation v1.2, not javax.annotation v1.0.

Opencast makes both javax.annotation v1.0 and v1.2 available. But, there are two paths to v1.2.

This package export order is good, no BootFeaturesInstaller constraint violation from two dependency chains:

karaf@root> package:exports
javax.annotation                                      | 1.0.0            | 0   | org.apache.felix.framework
javax.annotation                                      | 1.2.0            | 0   | org.apache.felix.framework
javax.annotation                                      | 1.2.0            | 27  | javax.annotation-api

This package export order appears to be associated with the BootFeaturesInstaller constraint violation from two dependency chains:

karaf@root> package:exports
javax.annotation                                      | 1.0.0            | 0   | org.apache.felix.framework
javax.annotation                                      | 1.2.0            | 27  | javax.annotation-api
javax.annotation                                      | 1.2.0            | 0   | org.apache.felix.framework

Karen Dolan
May 21, 2018, 5:58 PM

Found a possible thread-unsafe race condition in the Karaf Builder when it builds the "org.osgi.framework.system.packages.extra" from the assembly/pom.xml libraries.
Noted on Greg Logan's ticket https://issues.apache.org/jira/browse/KARAF-5693
Ref: https://github.com/apache/karaf/blob/karaf-4.0.10/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java#L703

Karen Dolan
June 8, 2018, 12:09 PM

Karaf github pull https://github.com/apache/karaf/pull/511 [KARAF-5693] Run the processing synchronously after downloads #511 gnodet (open as of 8 June 2018)

Karen Dolan
June 8, 2018, 3:42 PM

More TMI: The https://github.com/apache/karaf/pull/511 [KARAF-5693] is still open.

Example of dynamically assembled config.properties file size differences (note opencast-dist-adminworker):

33097 build/opencast-dist-admin-6-SNAPSHOT/opencast-dist-admin/etc/config.properties
33097 build/opencast-dist-adminpresentation-6-SNAPSHOT/opencast-dist-adminpresentation/etc/config.properties
32976 build/opencast-dist-adminworker-6-SNAPSHOT/opencast-dist-adminworker/etc/config.properties
33097 build/opencast-dist-allinone-6-SNAPSHOT/opencast-dist-allinone/etc/config.properties
33097 build/opencast-dist-ingest-6-SNAPSHOT/opencast-dist-ingest/etc/config.properties
33097 build/opencast-dist-migration-6-SNAPSHOT/opencast-dist-migration/etc/config.properties
33097 build/opencast-dist-presentation-6-SNAPSHOT/opencast-dist-presentation/etc/config.properties
33097 build/opencast-dist-worker-6-SNAPSHOT/opencast-dist-worker/etc/config.properties

Common missing lines in config.properties:

These 7:

javax.xml.bind;uses:=\"javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.namespace,javax.xml.stream,javax.xml.transform,javax.xml.validation,org.w3c.dom,org.xml.sax\";version=2.2.1, \
javax.xml.bind.annotation;uses:=\"javax.xml.bind,javax.xml.parsers,javax.xml.transform,javax.xml.transform.dom,org.w3c.dom\";version=2.2.1, \
javax.xml.bind.annotation.adapters;version=2.2.1, \
javax.xml.bind.attachment;uses:=javax.activation;version=2.2.1, \ javax.xml.bind.helpers;uses:=\"javax.xml.bind,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.stream,javax.xml.transform,javax.xml.validation,org.w3c.dom,org.xml.sax\";version=2.2.1, \
javax.xml.bind.util;uses:=\"javax.xml.bind,javax.xml.transform.sax\";version=2.2.1, \

And/Or these 3:

javax.annotation;version=1.2, \
javax.annotation.security;version=1.2, \
javax.annotation.sql;version=1.2, \

And/Or this 1:
javax.activation;version=1.1, \

Proposed comment Header in the static workaournd config.properties
################################################################################

  1.  

    1.  

      1.  

        1.  

          1.  

            1.  

              1.  

                1.  

                  1.  

                    1.  

                      1.  

                        1.  

                          1.  

                            1. OPENCAST PROJECT WARNING #######################################
                              ################################################################################

  2. This is a TEMPORARY fixed copy of a Karaf assembled config.properties

  3. The file is checked into source control as temporary workaround for (KARAF-5693)
    #

  4. https://opencast.jira.com/browse/MH-12905 "Karaf assembly omits extra system packages"

  5. https://issues.apache.org/jira/browse/KARAF-5693 "Incomplete config.properties file in built assemblies"

  6. https://github.com/apache/karaf/pull/511 [KARAF-5693] Run the processing synchronously after downloads #511 gnodet
    #

  7. CONSIDERATIONS:
    #

  8. I. IF you change from JAVA 8 to another version:

  9. REMOVE THIS FILE PRIOR TO BUILDING, verify the new file contains the expected set of libraries and check it into source control.
    #

  10. II. IF you modify assemblies/pom.xml libraries in the org.apache.karaf.tooling section

  11. REMOVE THIS FILE PRIOR TO BUILDING, verify the new file contains the expected set of libraries and check it into source control.
    #

  12. III. WHEN KARAF-5693 is resolved and absorbed into this Opencast version:

  13. This file will not be checked into source control. It will be dynamically created during the build.
    #
    #
    #############################################################################
    #####

Assignee

Unassigned

Reporter

Karen Dolan

Tags (folksonomy)

None

Components

Fix versions

Affects versions

Priority

Major
Configure