try to skip jaxb when not available in jaxrs
@@ -100,9 +100,14 @@ import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageUtils;
+import static java.lang.ClassLoader.getSystemClassLoader;
+
public final class InjectionUtils {
public static final Set<String> STANDARD_CONTEXT_CLASSES = new HashSet<>();
public static final Set<String> VALUE_CONTEXTS = new HashSet<>();
+
+ private static final boolean USE_JAXB;
+
static {
// JAX-RS 1.0-1.1
STANDARD_CONTEXT_CLASSES.add(Application.class.getName());
@@ -125,6 +130,19 @@ public final class InjectionUtils {
VALUE_CONTEXTS.add(Application.class.getName());
VALUE_CONTEXTS.add("javax.ws.rs.sse.Sse");
+
+ boolean useJaxb;
+ try {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null) {
+ loader = getSystemClassLoader();
+ }
+ loader.loadClass("javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter");
+ useJaxb = true;
+ } catch (final ClassNotFoundException cnfe) {
+ useJaxb = false;
+ }
+ USE_JAXB = useJaxb;
}
private static final Logger LOG = LogUtils.getL7dLogger(InjectionUtils.class);
@@ -458,7 +476,9 @@ public final class InjectionUtils {
boolean adapterHasToBeUsed = false;
Class<?> cls = pClass;
- Class<?> valueType = JAXBUtils.getValueTypeFromAdapter(pClass, pClass, paramAnns);
+ Class<?> valueType = !USE_JAXB
+ ? cls
+ : JAXBUtils.getValueTypeFromAdapter(pClass, pClass, paramAnns);
if (valueType != cls) {
cls = valueType;
adapterHasToBeUsed = true;
