Uploaded image for project: 'JBoss OSGi'
  1. JBoss OSGi
  2. JBOSGI-765

HostBundleClassLoader silently deletes JAXB annotations from Class if package not imported


    • Workaround:
      Workaround Exists
    • Workaround Description:

      Add the following to the Manifest:

      Import-Package: javax.xml.bind.annotations

      Add the following to the Manifest: Import-Package: javax.xml.bind.annotations


      Whenever an OSGI bundle contains JAXB-annotated classes, and Manifest of that bundle does not contain "Import-Package: javax.xml.bind.annotation" such bundle will be:

      1) Successfully installed
      2) Successfully activated
      3) All classes within said bundle will be properly loaded
      4) X.class.getDeclaredAnnotations() will return empty array if the only annotations on the class X are the annotations that reside in javax.xml.bind.annotation.

      No "NoClassDefFoundError" or "ClassNotFoundException" are ever thrown, no errors are logged. However, due to declared annotations not being present during class introspection, if such class X is used in with RESTEasy the following exception is thrown by the rest service:

      org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/xml

      if the return type of REST API call is List<X>.

      While workaround is quite simple (below), the concern is that such hidden behavior may result in other spurious failures of unknown origin in JAXB and elsewhere, since no indication that bundle resolution and linkage has failed is given anywhere.

      Marked Minor since workaround exists but I would recommend escalation.

        Gliffy Diagrams




              • Assignee:
                arcivanov Arcadiy Ivanov
                arcivanov Arcadiy Ivanov
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: