Re: [Resteasy-users] MarshalException when Return a list of Objects

2011-09-13 Thread kwground kwground
Problem solved. Just to share my experiences, looks like when I provide my
custom MessageBodyReader or MessageBodyWriter, I also need to make sure that
JaxbCollection is also in the same context that I use for marshalling the
object.

Thanks,

kw

On Tue, Sep 13, 2011 at 11:57 AM, kwground kwground wrote:

> What's frustrating is that when I do unit test via "BaseResourceTest",
> everything works. But when I run it in jboss, MarshalException was thrown.
>
> Here's sample resource:
>
> @Path("/api/id")
> public class MyIdentityService {
>  @GET
>  @Path("info/{ids}")
>  @Produces("application/xml")
>  @Wrapped(element = "profiles")
>  public Response info(@PathParam("ids") String ids) {
>   ArrayList set = new ArrayList();
>   String[] idds = ids.split(",");
>   for(String id : idds)
>set.add(new Profile(id));
>   GenericEntity> genericEntity = new
> GenericEntity>(set) {};
>   return Response.ok(genericEntity).build();
>  }
> }
> @XmlRootElement(name="profile")
> public class Profile {
>  private String id;
>
>  public SocialProfile(String id) {
>   this.id = id;
>  }
>
>  @XmlAttribute
>  public String getId() {
>   return id;
>  }
>  public void setId(String id) {
>   this.id = id;
>  }
> }
>
>
>
> On Mon, Sep 12, 2011 at 9:16 PM, kwground kwground wrote:
>
>> Hi,
>>
>> I'm still getting the this SAXException2 when I'm trying to return a list
>> of customer objects, folling what Bill's book, and also this link:
>>
>> http://fandry.blogspot.com/2010/06/response-objects-and-use-genericentity.html
>>
>>  2011-09-12 21:04:49,093 WARN
>>  [http-0.0.0.0-80-1:][SynchronousDispatcher] failed to execute
>> javax.ws.rs.WebApplicationException: javax.xml.bind.MarshalException
>>  - with linked exception:
>> [com.sun.istack.SAXException2: unable to marshal type
>> "java.util.ArrayList" as an element because it is missing an @XmlRootElement
>> annotation]
>> at
>> com.tungle.rest.spi.resteasy.plugins.moxy.MOXyMessageBodyReaderWriter.writeTo(MOXyMessageBodyReaderWriter.java:83)
>> at
>> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117)
>> at
>> org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.write(DigitalSigningInterceptor.java:39)
>> at
>> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
>> at
>> org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:63)
>> at
>> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
>> at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250)
>> at
>> org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:579)
>> at
>> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:500)
>> at
>> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
>> at
>> org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
>> at
>> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
>> at
>> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
>>
>> I googled, but couldn't find a solution. Please help. Thanks,
>>
>
>
--
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry® mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry® DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 ___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] MarshalException when Return a list of Objects

2011-09-13 Thread Bill Burke
Probably because you don't have the correct providers in your classpath 
on the client.

On 9/13/11 11:57 AM, kwground kwground wrote:
> What's frustrating is that when I do unit test via "BaseResourceTest",
> everything works. But when I run it in jboss, MarshalException was thrown.
> Here's sample resource:
> @Path("/api/id")
> public class MyIdentityService {
>   @GET
>   @Path("info/{ids}")
>   @Produces("application/xml")
>   @Wrapped(element = "profiles")
>   public Response info(@PathParam("ids") String ids) {
>ArrayList set = new ArrayList();
>String[] idds = ids.split(",");
>for(String id : idds)
> set.add(new Profile(id));
>GenericEntity> genericEntity = new
> GenericEntity>(set) {};
>return Response.ok(genericEntity).build();
>   }
> }
> @XmlRootElement(name="profile")
> public class Profile {
>   private String id;
>
>   public SocialProfile(String id) {
> this.id  = id;
>   }
>
>   @XmlAttribute
>   public String getId() {
>return id;
>   }
>   public void setId(String id) {
> this.id  = id;
>   }
> }
>
>
> On Mon, Sep 12, 2011 at 9:16 PM, kwground kwground  > wrote:
>
> Hi,
>
> I'm still getting the this SAXException2 when I'm trying to return a
> list of customer objects, folling what Bill's book, and also this link:
> 
> http://fandry.blogspot.com/2010/06/response-objects-and-use-genericentity.html
>
> 2011-09-12 21:04:49,093 WARN
>   [http-0.0.0.0-80-1:][SynchronousDispatcher] failed to execute
> javax.ws.rs.WebApplicationException: javax.xml.bind.MarshalException
>   - with linked exception:
> [com.sun.istack.SAXException2: unable to marshal type
> "java.util.ArrayList" as an element because it is missing an
> @XmlRootElement annotation]
> at
> 
> com.tungle.rest.spi.resteasy.plugins.moxy.MOXyMessageBodyReaderWriter.writeTo(MOXyMessageBodyReaderWriter.java:83)
> at
> 
> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117)
> at
> 
> org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.write(DigitalSigningInterceptor.java:39)
> at
> 
> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
> at
> 
> org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:63)
> at
> 
> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
> at
> org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250)
> at
> 
> org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:579)
> at
> 
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:500)
> at
> 
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
> at
> 
> org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
> at
> 
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
> at
> 
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
>
> I googled, but couldn't find a solution. Please help. Thanks,
>
>
>
>
> --
> BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
> Learn about the latest advances in developing for the
> BlackBerry® mobile platform with sessions, labs&  more.
> See new tools and technologies. Register for BlackBerry® DevCon today!
> http://p.sf.net/sfu/rim-devcon-copy1
>
>
>
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry® mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry® DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] MarshalException when Return a list of Objects

2011-09-13 Thread kwground kwground
What's frustrating is that when I do unit test via "BaseResourceTest",
everything works. But when I run it in jboss, MarshalException was thrown.

Here's sample resource:

@Path("/api/id")
public class MyIdentityService {
 @GET
 @Path("info/{ids}")
 @Produces("application/xml")
 @Wrapped(element = "profiles")
 public Response info(@PathParam("ids") String ids) {
  ArrayList set = new ArrayList();
  String[] idds = ids.split(",");
  for(String id : idds)
   set.add(new Profile(id));
  GenericEntity> genericEntity = new
GenericEntity>(set) {};
  return Response.ok(genericEntity).build();
 }
}
@XmlRootElement(name="profile")
public class Profile {
 private String id;

 public SocialProfile(String id) {
  this.id = id;
 }

 @XmlAttribute
 public String getId() {
  return id;
 }
 public void setId(String id) {
  this.id = id;
 }
}



On Mon, Sep 12, 2011 at 9:16 PM, kwground kwground  wrote:

> Hi,
>
> I'm still getting the this SAXException2 when I'm trying to return a list
> of customer objects, folling what Bill's book, and also this link:
>
> http://fandry.blogspot.com/2010/06/response-objects-and-use-genericentity.html
>
>  2011-09-12 21:04:49,093 WARN  [http-0.0.0.0-80-1:][SynchronousDispatcher]
> failed to execute
> javax.ws.rs.WebApplicationException: javax.xml.bind.MarshalException
>  - with linked exception:
> [com.sun.istack.SAXException2: unable to marshal type "java.util.ArrayList"
> as an element because it is missing an @XmlRootElement annotation]
> at
> com.tungle.rest.spi.resteasy.plugins.moxy.MOXyMessageBodyReaderWriter.writeTo(MOXyMessageBodyReaderWriter.java:83)
> at
> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117)
> at
> org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.write(DigitalSigningInterceptor.java:39)
> at
> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
> at
> org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:63)
> at
> org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
> at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250)
> at
> org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:579)
> at
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:500)
> at
> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
> at
> org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
> at
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
> at
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
>
> I googled, but couldn't find a solution. Please help. Thanks,
>
--
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry® mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry® DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 ___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] MarshalException when Return a list of Objects

2011-09-12 Thread kwground kwground
Hi,

I'm still getting the this SAXException2 when I'm trying to return a list of
customer objects, folling what Bill's book, and also this link:
http://fandry.blogspot.com/2010/06/response-objects-and-use-genericentity.html

2011-09-12 21:04:49,093 WARN  [http-0.0.0.0-80-1:][SynchronousDispatcher]
failed to execute
javax.ws.rs.WebApplicationException: javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.SAXException2: unable to marshal type "java.util.ArrayList"
as an element because it is missing an @XmlRootElement annotation]
at
com.tungle.rest.spi.resteasy.plugins.moxy.MOXyMessageBodyReaderWriter.writeTo(MOXyMessageBodyReaderWriter.java:83)
at
org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117)
at
org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.write(DigitalSigningInterceptor.java:39)
at
org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
at
org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:63)
at
org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250)
at
org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:579)
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:500)
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
at
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
at
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
at
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

I googled, but couldn't find a solution. Please help. Thanks,
--
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry® mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry® DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 ___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users