2 Replies Latest reply on Jun 19, 2013 12:14 PM by kcbabo

    rest calls another rest, but classCastException while passing around POJO

    seungchan.lee-evault.com

      Hi All,

       

      I have a rest service and from its bean calls another rest service.  When the service returns void or String, everything looks good.  However, when it comes time to pass around POJO, I'm getting ClassCastException ...  It looks like I need to writer Transformers, but I have no idea how to write and where to put.  Could anyone direct me to where to find any tutorial or sample project ... or at least give me some direction?

       

      Thanks a lot!!

        • 1. Re: rest calls another rest, but classCastException while passing around POJO
          seungchan.lee-evault.com

          I think I should rephrase this question ...

           

          I have a rest service:

          @Path("/")

          @Produces("application/json")

          public interface DataServiceResource {

              @GET

              @Path("/account/{param}")

              Account getAccount(@PathParam("param") String accountId);

          }

           

          I have another service which uses this DataService from inside of bean:

          @Service(HelloRestService.class)

          public class HelloRestServiceBean implements HelloRestService {

               @Override

              public Account getAccount(String accountId) {

                 

                 Account a = dataService.getAccount(accountId);

                 return al;

              }

          ..

          }

           

          Obviously, DataService getAccount() returns the json representation of Account instance and ths line Account a = dataService.getAccount(accountId); in HelloRestServiceBean throws ClassCastException without any transform, I think.  I'd like to know how to write this transformer and where to put it??

           

          Thanks

          • 2. Re: rest calls another rest, but classCastException while passing around POJO
            kcbabo

            Attach the entire application and we can provide some advice.