You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Tony Dahbura <da...@aopslab.com> on 2011/06/01 20:52:44 UTC

Help with Jersey Rest Services and Cayenne

I am utilizing the JAXB annotations to convert my objects from Cayenne into XML and/or Jason format. The Jersey/JAXB libraries are complaining: 

SEVERE: Mapped exception to response: 500 (Internal Server Error) 
javax.ws.rs.WebApplicationException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 7 counts of IllegalAnnotationExceptions 
org.apache.cayenne.access.DataContextDelegate is an interface, and JAXB can't handle interfaces. 
this problem is related to the following location: 
at org.apache.cayenne.access.DataContextDelegate 

I have read elsewhere on this problem but am not quite clear on how to get around this. Can someone offer some guidance? 

Thanks so much-this group is great! 
Tony 


Re: Help with Jersey Rest Services and Cayenne

Posted by Andrus Adamchik <an...@objectstyle.org>.
Very cool. Please also take a look at the link that I posted: 

> http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-serialization/

You may not use any of the actual code, but I hope the idea of defining a "serialization spec" based on a subset of the existing Cayenne mapping metadata has some merit and is pretty flexible.

Andrus



On Jun 7, 2011, at 2:11 AM, Marek Šabo wrote:
> Hi,
> 
> I think something was discussed here some time ago http://www.mail-archive.com/user@cayenne.apache.org/msg05674.html.
> 
> I have this in my TODO but it has to be "two birds - one rock" in my case, so if my thesis submission pushes through I will be implementing the marshaller (complex relationships are bloated in DTOs anyway).
> 
> Regards,
> 
> Marek
> 
> On 06/02/2011 01:57 PM, Andrus Adamchik wrote:
>> On Jun 2, 2011, at 2:43 PM, Andrus Adamchik wrote:
>> 
>>> XML (or other types of serialization) of framework-managed objects is a pretty involved topic. So my advise would be to use your own POJO data transfer objects (DTO) to work with JAXB (those can be auto generated from the model with custom templates if you want).
>> And I wish at some point we'd create JAXB bindings for Cayenne. Just that nobody volunteered to do that yet. We took a few shots at various XML serialization implementations. The most notable are:
>> 
>> 1. http://cayenne.apache.org/doc30/api/org/apache/cayenne/xml/package-summary.html
>> 
>> Working, but has severe performance limitations. Deprecated in 3.1 and will be removed from Cayenne in the future.
>> 
>> 2. http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-serialization/
>> 
>> A proof of concept that I wrote for metadata-driven XStream-based serializer (can work with JSON or XML). I like this one. It provides fine-grained control over which parts of the object graph are serialized and is generally more flexible than 1. However it still requires significant work to make it production-quality.
>> 
>> 3. Finally the JAXB integration was an idea that was floated around, but hasn't materialized yet.
>> 
>> Any interested parties are welcomed to jump on the dev list and discuss this further (and offer help!).
>> 
>> Cheers,
>> Andrus
> 


Re: Help with Jersey Rest Services and Cayenne

Posted by Marek Šabo <ms...@buk.cvut.cz>.
Hi,

I think something was discussed here some time ago 
http://www.mail-archive.com/user@cayenne.apache.org/msg05674.html.

I have this in my TODO but it has to be "two birds - one rock" in my 
case, so if my thesis submission pushes through I will be implementing 
the marshaller (complex relationships are bloated in DTOs anyway).

Regards,

Marek

On 06/02/2011 01:57 PM, Andrus Adamchik wrote:
> On Jun 2, 2011, at 2:43 PM, Andrus Adamchik wrote:
>
>> XML (or other types of serialization) of framework-managed objects is a pretty involved topic. So my advise would be to use your own POJO data transfer objects (DTO) to work with JAXB (those can be auto generated from the model with custom templates if you want).
> And I wish at some point we'd create JAXB bindings for Cayenne. Just that nobody volunteered to do that yet. We took a few shots at various XML serialization implementations. The most notable are:
>
> 1. http://cayenne.apache.org/doc30/api/org/apache/cayenne/xml/package-summary.html
>
> Working, but has severe performance limitations. Deprecated in 3.1 and will be removed from Cayenne in the future.
>
> 2. http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-serialization/
>
> A proof of concept that I wrote for metadata-driven XStream-based serializer (can work with JSON or XML). I like this one. It provides fine-grained control over which parts of the object graph are serialized and is generally more flexible than 1. However it still requires significant work to make it production-quality.
>
> 3. Finally the JAXB integration was an idea that was floated around, but hasn't materialized yet.
>
> Any interested parties are welcomed to jump on the dev list and discuss this further (and offer help!).
>
> Cheers,
> Andrus

Re: Help with Jersey Rest Services and Cayenne

Posted by Tony Dahbura <da...@aopslab.com>.
Thanks!

I wish we could get the JAXB integration into Cayenne that would be a great asset for the work we use.  I am not sure if we could tackle it here or not.

Tony


----- Original Message -----
From: "Andrus Adamchik" <an...@objectstyle.org>
To: user@cayenne.apache.org
Sent: Thursday, June 2, 2011 7:57:35 AM
Subject: Re: Help with Jersey Rest Services and Cayenne


On Jun 2, 2011, at 2:43 PM, Andrus Adamchik wrote:

> XML (or other types of serialization) of framework-managed objects is a pretty involved topic. So my advise would be to use your own POJO data transfer objects (DTO) to work with JAXB (those can be auto generated from the model with custom templates if you want). 

And I wish at some point we'd create JAXB bindings for Cayenne. Just that nobody volunteered to do that yet. We took a few shots at various XML serialization implementations. The most notable are:

1. http://cayenne.apache.org/doc30/api/org/apache/cayenne/xml/package-summary.html

Working, but has severe performance limitations. Deprecated in 3.1 and will be removed from Cayenne in the future.

2. http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-serialization/

A proof of concept that I wrote for metadata-driven XStream-based serializer (can work with JSON or XML). I like this one. It provides fine-grained control over which parts of the object graph are serialized and is generally more flexible than 1. However it still requires significant work to make it production-quality.

3. Finally the JAXB integration was an idea that was floated around, but hasn't materialized yet.

Any interested parties are welcomed to jump on the dev list and discuss this further (and offer help!).

Cheers,
Andrus

Re: Help with Jersey Rest Services and Cayenne

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Jun 2, 2011, at 2:43 PM, Andrus Adamchik wrote:

> XML (or other types of serialization) of framework-managed objects is a pretty involved topic. So my advise would be to use your own POJO data transfer objects (DTO) to work with JAXB (those can be auto generated from the model with custom templates if you want). 

And I wish at some point we'd create JAXB bindings for Cayenne. Just that nobody volunteered to do that yet. We took a few shots at various XML serialization implementations. The most notable are:

1. http://cayenne.apache.org/doc30/api/org/apache/cayenne/xml/package-summary.html

Working, but has severe performance limitations. Deprecated in 3.1 and will be removed from Cayenne in the future.

2. http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-serialization/

A proof of concept that I wrote for metadata-driven XStream-based serializer (can work with JSON or XML). I like this one. It provides fine-grained control over which parts of the object graph are serialized and is generally more flexible than 1. However it still requires significant work to make it production-quality.

3. Finally the JAXB integration was an idea that was floated around, but hasn't materialized yet.

Any interested parties are welcomed to jump on the dev list and discuss this further (and offer help!).

Cheers,
Andrus

Re: Help with Jersey Rest Services and Cayenne

Posted by Andrus Adamchik <an...@objectstyle.org>.
This means that your serializer tries to serialize DataContext attached to DataObjects. Which is strange, as "objectContext" property of a PersistentObject is declared as "transient", so you would think it should be skipped by JAXB (??)

XML (or other types of serialization) of framework-managed objects is a pretty involved topic. So my advise would be to use your own POJO data transfer objects (DTO) to work with JAXB (those can be auto generated from the model with custom templates if you want). 

I am using Jersey/JAXB/JSON/XML with Cayenne a lot myself. However I've never had to deal with direct serialization and for a different reason - the data that I want to expose to my end users never has one-to-one correspondence with the database model. So an extra DTO layer allows me to tweak the output for a particular type of Jersey resource.

Andrus


On Jun 1, 2011, at 9:52 PM, Tony Dahbura wrote:
> I am utilizing the JAXB annotations to convert my objects from Cayenne into XML and/or Jason format. The Jersey/JAXB libraries are complaining: 
> 
> SEVERE: Mapped exception to response: 500 (Internal Server Error) 
> javax.ws.rs.WebApplicationException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 7 counts of IllegalAnnotationExceptions 
> org.apache.cayenne.access.DataContextDelegate is an interface, and JAXB can't handle interfaces. 
> this problem is related to the following location: 
> at org.apache.cayenne.access.DataContextDelegate 
> 
> I have read elsewhere on this problem but am not quite clear on how to get around this. Can someone offer some guidance? 
> 
> Thanks so much-this group is great! 
> Tony 
>