]
Arcadiy Ivanov reassigned JBOSGI-765:
-------------------------------------
Assignee: Arcadiy Ivanov
HostBundleClassLoader silently deletes JAXB annotations from Class if
package not imported
------------------------------------------------------------------------------------------
Key: JBOSGI-765
URL:
https://issues.jboss.org/browse/JBOSGI-765
Project: JBoss OSGi
Issue Type: Bug
Components: framework
Affects Versions: JBossOSGi 2.2.0
Environment: WildFly 8.1.0.Final
Reporter: Arcadiy Ivanov
Assignee: Arcadiy Ivanov
Priority: Minor
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.