You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "J. Fiala" <mo...@fwd.at> on 2016/08/17 16:53:57 UTC

CXF JAXRS wadl2java - ObjectFactory.java causes MarshalException

I'm using wadl2java to generate api and model classes from a WADL (CXF 
3.1.6).

I'm using the JacksonProvider in the client call:

JacksonJsonProvider provider = new JacksonJsonProvider();
List<Object> providers = new ArrayList<Object>();
providers.add(provider);
api = JAXRSClientFactory.create(serverApp, MyApiResource.class, providers);

However, the generated ObjectFactory.java seems to overrule the Json 
provider and throws the following exception:

WARNING: javax.xml.bind.MarshalException
  - with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type 
"at.myapp.MyCustomType" as an element because it is missing an 
@XmlRootElement annotation]

If I remove the ObjectFactory.java from the buildpath 
(<exclude>**/at/myapp/ObjectFactory.java</exclude> in pom.xml), then 
everything is working like a charm (Json gets assembled/parsed correctly).

This problem doesn't exist if I use CXF 2, there everything is working 
out of the box.

Is there another way to get the CXF 3 client working with wadl2java 
without removing ObjectFactory.java from the buildpath?

Best regards,
J. Fiala


Re: CXF JAXRS wadl2java - ObjectFactory.java causes MarshalException

Posted by "J. Fiala" <mo...@fwd.at>.
Sergey,

Correct, removed the jettison from the classpath and everything works 
without excluding...!

Best regards,
Johannes


Am 18.08.2016 um 00:27 schrieb Sergey Beryozkin:
> Looks like you have CXF JSONProvider loaded...
>
> Sergey
> On 17/08/16 17:53, J. Fiala wrote:
>> I'm using wadl2java to generate api and model classes from a WADL (CXF
>> 3.1.6).
>>
>> I'm using the JacksonProvider in the client call:
>>
>> JacksonJsonProvider provider = new JacksonJsonProvider();
>> List<Object> providers = new ArrayList<Object>();
>> providers.add(provider);
>> api = JAXRSClientFactory.create(serverApp, MyApiResource.class, 
>> providers);
>>
>> However, the generated ObjectFactory.java seems to overrule the Json
>> provider and throws the following exception:
>>
>> WARNING: javax.xml.bind.MarshalException
>>  - with linked exception:
>> [com.sun.istack.internal.SAXException2: unable to marshal type
>> "at.myapp.MyCustomType" as an element because it is missing an
>> @XmlRootElement annotation]
>>
>> If I remove the ObjectFactory.java from the buildpath
>> (<exclude>**/at/myapp/ObjectFactory.java</exclude> in pom.xml), then
>> everything is working like a charm (Json gets assembled/parsed 
>> correctly).
>>
>> This problem doesn't exist if I use CXF 2, there everything is working
>> out of the box.
>>
>> Is there another way to get the CXF 3 client working with wadl2java
>> without removing ObjectFactory.java from the buildpath?
>>
>> Best regards,
>> J. Fiala
>>
>
>


Re: CXF JAXRS wadl2java - ObjectFactory.java causes MarshalException

Posted by Sergey Beryozkin <sb...@gmail.com>.
Looks like you have CXF JSONProvider loaded...

Sergey
On 17/08/16 17:53, J. Fiala wrote:
> I'm using wadl2java to generate api and model classes from a WADL (CXF
> 3.1.6).
>
> I'm using the JacksonProvider in the client call:
>
> JacksonJsonProvider provider = new JacksonJsonProvider();
> List<Object> providers = new ArrayList<Object>();
> providers.add(provider);
> api = JAXRSClientFactory.create(serverApp, MyApiResource.class, providers);
>
> However, the generated ObjectFactory.java seems to overrule the Json
> provider and throws the following exception:
>
> WARNING: javax.xml.bind.MarshalException
>  - with linked exception:
> [com.sun.istack.internal.SAXException2: unable to marshal type
> "at.myapp.MyCustomType" as an element because it is missing an
> @XmlRootElement annotation]
>
> If I remove the ObjectFactory.java from the buildpath
> (<exclude>**/at/myapp/ObjectFactory.java</exclude> in pom.xml), then
> everything is working like a charm (Json gets assembled/parsed correctly).
>
> This problem doesn't exist if I use CXF 2, there everything is working
> out of the box.
>
> Is there another way to get the CXF 3 client working with wadl2java
> without removing ObjectFactory.java from the buildpath?
>
> Best regards,
> J. Fiala
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/