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 7D5B6200B74 for ; Thu, 18 Aug 2016 00:26:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7BA6E160AB5; Wed, 17 Aug 2016 22:26:01 +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 9CEF6160A8C for ; Thu, 18 Aug 2016 00:26:00 +0200 (CEST) Received: (qmail 25268 invoked by uid 500); 17 Aug 2016 22:25:59 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 25252 invoked by uid 99); 17 Aug 2016 22:25:59 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2016 22:25:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id F05731A57C9 for ; Wed, 17 Aug 2016 22:25:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.821 X-Spam-Level: X-Spam-Status: No, score=-0.821 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id iMGe1qsjRK8Z for ; Wed, 17 Aug 2016 22:25:56 +0000 (UTC) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 344325F201 for ; Wed, 17 Aug 2016 22:25:56 +0000 (UTC) Received: by mail-wm0-f54.google.com with SMTP id q128so220845186wma.1 for ; Wed, 17 Aug 2016 15:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=L78nrszNWhGPUrkTHUX9RBP3mEM1QaTaN26hZ0nlso4=; b=oqWNT+LP4iyhIuCRd4c6p2dMRmTkYy+epI9zVC+/cXZT1DJ9RxqFPXH3hQ36viwEBs jE0JU7kUxBZM0YhwpPBmiFF2eE5nxqeD/MGgE3tbA8ftLI3GOWY0fI9daKXJXpEqbokv OpCqs5K5bPHt3LrMdcZarqxdcVoNfwWnRLdihSxko6Yfo7Gv54ybNXxE3E7gBGj7vmTg Jy69ces/a0Aqhf1gKQBLhK4GHu7mFsdz0ixFfJOpRBt/3ueJ336DyVbjV2ZbxoHI5V59 VbtuU9mODgOvkIChuFoSd8EwHN8hzfgh24pluL1/eBnY/KkuTW7uBjZPp/k+lJg+AA8L jElA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=L78nrszNWhGPUrkTHUX9RBP3mEM1QaTaN26hZ0nlso4=; b=QmJPpXT42qg4osFyBP6E6L+ciZioZZKxUuNvlqgkYRtm/dmemAzM8FLAxmexz1oSRO 7Wv91bv+zgagC4ZB8Z8aBc20sGZEKxEGfWY3ydjo56qmAuJJsKQsXP96LGOCRkIZRwGA MHxcd4YRmJHkmCAdaByk2IBRBSdhBwtpKdeeKiH2YeDtFRZHhpmelSeHf9Rm4edGOu7H iCdDRhsvVou2awuhOlCSWk6/yQ55Z8XpJ+prz6b1LvJWkbiDGjhmUQCBOzKaSQWHQObl kMRiQZa+1+nokBT6OQuiEBmTv07GY9T76Wzpn7RxnEjeks96isSVM7f1e4m/z63AcRAi QBOw== X-Gm-Message-State: AEkooutCMnilOMXodifeoKT/h90rkanumXKyzdncr/7LesyzxOlAkbBbtAHb0Rli3fxOjg== X-Received: by 10.28.51.210 with SMTP id z201mr29020091wmz.98.1471472754026; Wed, 17 Aug 2016 15:25:54 -0700 (PDT) Received: from [192.168.2.7] ([79.97.121.181]) by smtp.googlemail.com with ESMTPSA id a184sm410683wmh.1.2016.08.17.15.25.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Aug 2016 15:25:53 -0700 (PDT) Subject: Re: Spring Boot CXF JAX-RS and Jackson Provider To: users@cxf.apache.org References: <9c1f6bc4-5fd0-1c92-2a30-c2f0ac7fd782@gmail.com> From: Sergey Beryozkin Message-ID: <32515338-8b54-640b-ae45-6281c4e850ea@gmail.com> Date: Wed, 17 Aug 2016 23:25:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit archived-at: Wed, 17 Aug 2016 22:26:01 -0000 Hi Oh, I thought SpringBoot made XML config a history :-) I'll need to document it at CXF SpringBoot wiki page. Can you give me a favor and double check that you have no Jettison library somewhere on the classpath ? If it is available then CXF will auto-create its own CXF JSONProvider which is more specific than Jackson (FYI it has wildcard Consumes/Produces which makes it less specific compared to other provider candidates) Cheers, Sergey On 17/08/16 18:02, J. Fiala wrote: > Sergey, > > Thank you for the quick response! > > I'm using cxf-spring-boot-starter-jaxrs 3.1.7 with Spring Boot > 1.3.3.RELEASE. > > You only have to add the XML using @ImportResource, then it is working > immediately: > > @ImportResource({"classpath:/mySpringContext.xml"}) > @EnableAutoConfiguration > public class Application extends SpringBootServletInitializer { > > @Override > protected SpringApplicationBuilder > configure(SpringApplicationBuilder application) { > return application.sources(Application.class); > } > > public static void main(String[] args) { > SpringApplication.run(Application.class, args); > } > > > } > > We have lots of existing spring XML configurations so we like to reuse > them. > > Inside the XML configuration the JacksonProvider is declared and > connected to the endpoints: > > class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" /> > > > > > > > > > > > > > > > So the Jackson Provider should be picked up when the Spring > configuration is used by the Spring Boot starter. > > In fact, I think the @Xml..-annotations in the model classes are causing > the issue (generated using wadl2java). > If you like, I can provide a sample using wadl2java generated classes > based on your sample (spring_boot_scan) and try to reproduce the issue. > > Best regards, > Johannes > > > Am 17.08.2016 um 18:52 schrieb Sergey Beryozkin: >> Hi >> >> To be honest I'm not sure traditional Spring XML configuration files >> are even supported with Spring Boot ? (XML is the old citizen, >> properties is the new citizen :-)), but if it is then let me know how. >> >> Are you using CXF 3.1.7 Spring Boot starter ? >> >> I think you need to have a @Bean method returning >> new JacksonJsonProvider() >> >> It can also be auto-scanned - but I found in my experiments that >> muiltiple Jackson providers can be picked up, so I'd rather return an >> instance from the code >> >> Sergey >> On 17/08/16 17:40, J. Fiala wrote: >>> I try to run a CXF JAX-RS endpoint using Spring XML configuration and >>> Spring Boot. >>> >>> The services are listed correctly when I access the server and the >>> WADL/Swagger endpoint is generated correctly: >>> >>> http://localhost:8080/services/ >>> >>> The API methods are annoted with: >>> @Consumes("application/json") >>> @Produces("application/json") >>> >>> However, when I invoke any service using Json, I get: >>> >>> |JAXBException occurred : unable to marshal type "..." as an element >>> because it is missing an @XmlRootElement annotation. unable to marshal >>> type "..." as an element because it is missing an @XmlRootElement >>> annotation. | >>> >>> I'm using wadl2java to generate the api and model classes at server side >>> from the WADL, so there are @XmlAccessorType/@XmlType annotation in my >>> model classes on the server side. >>> >>> Spring-Boot/CXF seems ignore the provider configured in the Spring >>> configuration XML (which is working perfectly if deployed without Spring >>> Boot to e.g. Jboss/Tomcat): >>> >> class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" /> >>> >>> How can I set the JacksonJsonProvider to be used by Spring Boot/CXF, or >>> are model classes annotated with @Xml... not supported for Spring >>> Boot/CXF? >>> >>> Best regards, >>> Johannes >>> >>> >> >> > -- Sergey Beryozkin Talend Community Coders http://coders.talend.com/