In my (JIRA) plugin, I have ActiveObjects configured with a domain model, which I now want to expose through a REST interface. I have added a REST module and injected the ActiveObjects into it, so access to the domain model entites does work.
However, how do I expose the entities through the REST service? For example with a Todo entity, I tried to simply do
return Response.ok(todoEntity).build()
but it fails, basically with
A message body writer for Java class com.sun.proxy.$Proxy2813, and Java type class com.sun.proxy.$Proxy2813, and MIME media type application/xml was not found
I have also tried to annotate the Todo entity definition (which has to be an interface) with @XmlRootElement, etc. but it does not seem to help.
Is it truely required to copy data from AO entity objects into REST objects back and forth? (I understand that it may be desireable to separate these, but in effect they will be the same for my project).
Community moderators have prevented the ability to post new answers.
I did not find another solution to this and ended up with writing objects and code to move back an forth between REST objects and AO entities. Not elegant, but it works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That post does not seem to be of much help. The recommendation is to annotate the model class with annotations to define the serialization/mapping. However, since an ActiveObjects entity is defined through an interface, while the actual object to be serialized is a (dynamically created) proxy, that approach does not help.
As I said, I already tried to annotate the Todo entity interface, but it did not have any effect on the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you,re right I've missed the fact that with AO you've got proxies. It seems that what you're trying to do is quite hard and maybe impossible. Here's some discussions on that
https://answers.atlassian.com/questions/19413/combining-active-object-entities-with-jaxb-annotations-any-implementation-examples
https://answers.atlassian.com/questions/119357/rest-activeobjects-jsonmappingexception
So I would advice you to create a separate model (as you already know) for the REST repsponse.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.