Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3949

NoClassDefFoundError when using CXF JAX-RS in OSGi environment

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.4.9, 2.5.5, 2.6.2, 2.7
    • Component/s: JAX-RS
    • Labels:
      None
    • Environment:

      ServiceMix 4.3

    • Estimated Complexity:
      Moderate

      Description

      When using the CXF JAX-RS implementation in an OSGi environment, the CXF implementation might fail to initialize properly.
      The problem is non-consistently reproduceable, but more likely to occur on machines with high parallelism (due to several cores/threads).
      The CXF bundle ("org.apache.cxf.bundle") has a dependency on the JSR 311 API JAR ("org.apache.servicemix.specs.jsr311-api-1.1").
      But the dependency is marked as "resolution=optional" in the OSGi headers of the CXF bundle manifest.
      As a result, if the JSR-311 bundle is not yet fully started when the CXF bundle is started, OSGi does not "wire" these packages into the imports of the CXF bundle:
      javax.ws.rs
      javax.ws.rs.core
      javax.ws.rs.ext

      The error is the following :
      java.lang.NoClassDefFoundError: Could not initialize class org.apache.cxf.jaxrs.utils.JAXRSUtils
      See similar error DOSGI-1

      I guess that these packages are marked as optional because CXF can be used in an environment where no JAX-RS is available, and it works fine as long as the application does not use this API. However, when an application is known to use the API, the dependency marked as "optional" is not correct.

      Long-term solution : split CXF bundle into smaller bundles (like Jetty).

      Workaround : edit the manifest of the CXF bundle, and remove the "resolution=optional" for the packages which are known to be used by the application. Tip : replace "resolution" by "resolutio2", this tricks prevents from changing the alignment of the 80-characters columns.

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              metatech metatech

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 8h
                8h
                Remaining:
                Remaining Estimate - 8h
                8h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Issue deployment