Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 11BB3200C63 for ; Thu, 11 May 2017 10:15:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 10516160BC7; Thu, 11 May 2017 08:15:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 56CC1160BB2 for ; Thu, 11 May 2017 10:15:08 +0200 (CEST) Received: (qmail 14443 invoked by uid 500); 11 May 2017 08:15:07 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 14432 invoked by uid 99); 11 May 2017 08:15:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 May 2017 08:15:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D308E1806A4 for ; Thu, 11 May 2017 08:15:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id Da90LcTtcW8Q for ; Thu, 11 May 2017 08:15:05 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 46CAE5FBE2 for ; Thu, 11 May 2017 08:15:05 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 89236E01A8 for ; Thu, 11 May 2017 08:15:04 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 3B59021DEB for ; Thu, 11 May 2017 08:15:04 +0000 (UTC) Date: Thu, 11 May 2017 08:15:04 +0000 (UTC) From: "Lukas Rohner (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (CXF-7368) JAXB provider is handling non-jaxb classes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 11 May 2017 08:15:09 -0000 Lukas Rohner created CXF-7368: --------------------------------- Summary: JAXB provider is handling non-jaxb classes Key: CXF-7368 URL: https://issues.apache.org/jira/browse/CXF-7368 Project: CXF Issue Type: Bug Components: JAX-RS Affects Versions: 3.1.11 Reporter: Lukas Rohner The default JSONProvider is trying to marshal a non-jaxb class which results in a 500 response of my endpoint. One of my endpoints is returning a StreamingOutput object to the response object: {noformat} public static Response okJson(JValue json) { return Response.ok(new StreamingOutput() { @Override public void write(OutputStream s) throws IOException, WebApplicationException { try (final BufferedOutputStream bs = new BufferedOutputStream(s)) { serializer.fn.toJson(json).apply(bs); } } }, MediaType.APPLICATION_JSON_TYPE).build(); } {noformat} Unfortunately, the default JSONProvider is trying to marshal this class because it thinks it is a jaxb supported class. This support check happens in the AbstractJAXBProvider class: {noformat} protected boolean isSupported(Class type, Type genericType, Annotation[] anns) { if (jaxbElementClassMap != null && jaxbElementClassMap.containsKey(type.getName()) || isSkipJaxbChecks()) { return true; } return isXmlRoot(type) || JAXBElement.class.isAssignableFrom(type) || objectFactoryOrIndexAvailable(type) || (type != genericType && objectFactoryForType(genericType)) || org.apache.cxf.jaxrs.utils.JAXBUtils.getAdapter(type, anns) != null; } protected boolean objectFactoryOrIndexAvailable(Class type) { return type.getResource("ObjectFactory.class") != null || type.getResource("jaxb.index") != null; } {noformat} The issue is that the objectFactoryOrIndexAvailable is returning true which doesn't indicate that the type itself is a jaxb class. To fix the support mehtod it should actually check if there is and jaxb.index file and if in the index file the current type is available. Then we can clearly say it's a jaxb supported class. -- This message was sent by Atlassian JIRA (v6.3.15#6346)