Running  RestEasy 2.3.5

We are looking at exposing many of our EJB services thru RestEasy.   One of our 
thoughts is to return a common object that contains a reference to the resource 
or list of resources.   The object would look like below, where the resource or 
list of resources would be saved in the messageObject field.   This fails when 
Resteasy tries to find the correct message writer.

package rest;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "RestfulResponse")
public class RestfulResponse {

        private long statusCode;
        private String statusDescription;
        private Object messageObject;
        private String excpDetails;

        public long getStatusCode() {
                return statusCode;
        public void setStatusCode(long statusCode) {
                this.statusCode = statusCode;

        public String getStatusDescription() {
                return statusDescription;
        public void setStatusDescription(String statusDescription) {
                this.statusDescription = statusDescription;

        public String getExcpDetails() {
                return excpDetails;
        public void setExcpDetails(String excpDetails) {
                this.excpDetails = excpDetails;

        public Object getMessageObject() {
                return messageObject;
        public void setMessageObject(Object messageObject) {
                this.messageObject = messageObject;


I tried adjusting my resource method to use the GenericEntity class but must 
have gotten that wrong, see exception below.

        @Produces({"application/json", "application/xml"})
        public RestfulResponse findAll(@QueryParam(BaseResource.OFFSET) 
@DefaultValue("0") String offset, @QueryParam(BaseResource.LIMIT) 
@DefaultValue("10") String limit)
                List<EnvironmentBean> list = null;
                EnvironmentServiceLocal envSvc = 
                RestfulResponse response = new RestfulResponse();

                try {
                        if (isRetrieveAllAllowed()) {
                                list = envSvc.findAll();
                        } else {
                                validatePaginationParms(offset, limit);
                                list = 
                } catch (FinderException e) {
                        return response;
                GenericEntity<List<EnvironmentBean>> entity = new 
GenericEntity<List<EnvironmentBean>>(list) {};
                return response;

 - with linked exception:
[javax.xml.bind.JAXBException: rest.EnvironmentResource$1 nor any of its super 
class is known to this context]
        . . .

This seems to work okay if I use the class and set 
the entities in there.  We wanted the option to return some additional 
'metadata' about the requests if appropriate, like a total count in a metadata 
field somewhere when getting a list of resources.   Is there a better way to do 
what we are trying to do?

Just setting the messageObject to the list reference gives exception:  
JAXBException: java.util.ArrayList nor any of its super class is known to this 

How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
Resteasy-users mailing list

Reply via email to