Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-213

Bug in client-framework and interface inheritance

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.1.RC1
    • 1.0.2.GA
    • None
    • None

    Description

      orry for the terrible subject and the second post, seems my first one did not take...

      This seems like such an obvious issue that I am surprised I have not found it in jira. As soon as I start to subclass my interfaces as in the following example the client chokes a bit unexpectedly.

      Environment = RestEasy 1.0.2.GA, OS X, java 1.5

      Webservice base url = http://localhost:8080/ws

      =================================================
      ClientTest.java
      =================================================
      @RunWith(SpringJUnit4ClassRunner.class)
      @ContextConfiguration(locations=

      {"/webservices-client-context.xml"}

      )
      public class ClientTest {

      @Resource
      private ServiceLocation serviceLocation;

      @Test
      public void testBasic()

      { RegisterBuiltin.register(ResteasyProviderFactory.getInstance()); UserEntity u = new UserEntity(); u.setUsername("user"); UserEntityWebservice serviceClient = ProxyFactory.create(UserEntityWebservice.class, serviceLocation.getUrl()); UserEntity newUser = serviceClient.create(u); System.out.println("**** " + newUser.getUsername()); }

      }

      =================================================
      UserEntity.java
      =================================================
      @XmlAccessorType(XmlAccessType.NONE)
      @XmlRootElement(name="user")
      public class UserEntity {

      @XmlElement
      private String username;

      public UserEntity()

      { super(); }

      public String getUsername()

      { return username; }

      public void setUsername(String username)

      { this.username = username; }

      }

      =================================================
      UserEntityWebservice.java
      =================================================
      @Path("/user")
      @Produces(

      {"application/xml","application/json"})
      @Consumes({"application/xml","application/json"}

      )
      public interface UserEntityWebservice extends CRUDEntityWebservice {

      }

      =================================================
      CRUDEntityWebservice.java
      =================================================
      public interface CRUDEntityWebservice {

      @POST
      @Path("/")
      public UserEntity create( UserEntity entity );
      }

      If I run this as is I get:

      java.lang.RuntimeException: You must define a @ConsumeMime type on your client method or interface
      at org.jboss.resteasy.client.core.ClientMarshallerFactory.createMarshaller(ClientMarshallerFactory.java:104)

      If I add the annotation to the CRUDEntityWebservice as this:

      @Produces(

      {"application/xml","application/json"})
      @Consumes({"application/xml","application/json"}

      )
      public interface CRUDEntityWebservice {

      @POST
      @Path("/")
      public UserEntity create( UserEntity entity );
      }

      I get a 404 error and the log shows that it's not getting the correct path built.

      [DEBUG] wire.header >> "POST /paymentobjects-webservices/ws/ HTTP/1.1[\r][\n]"
      org.jboss.resteasy.client.ClientResponseFailure: Error status 404 Not Found returned

      Finally if I add a add a Path to the CRUD interface it all works fine:

      @Path("/usr")
      @Produces(

      {"application/xml","application/json"})
      @Consumes({"application/xml","application/json"}

      )
      public interface CRUDEntityWebservice {

      @POST
      @Path("/")
      public UserEntity create( UserEntity entity );
      }

      This seems like such an obvious use case that I am quite surprised that I am running into it. If this is the way things are supposed then I would have to flatten out my Webservice interfaces to make this work which just sounds silly. Is there something that I am doing wrong?

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            patriot1burke@gmail.com Bill Burke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: