Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5214

Using BeanParam in a subresource results in exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.6
    • 2.7.7, 3.0.0-milestone1
    • JAX-RS
    • None
    • Unknown

    Description

      I'm unable to use a @BeanParam in subresource without specifying the bean parameter in the first method call as a method parameter in the resource call chain. In pseudo code:

      class Bean {
      @QueryParam("name")
      private String name;
      ... getters/setters
      }
      @Path("/")
      @Produces(MediaType.PLAIN_TEXT)
      class Root {
      @Context private ResourceContext resources;

      @GET public String get()

      { return "/hello"; }

      @Path("hello")
      public HelloResource hello()

      { return resources.getResource(HelloResource.class); }

      }

      class HelloResource {
      @BeanParam
      private Bean params;

      @GET
      public String get()

      { return "Hello, " + params.getName() + "!"; }

      }

      This fails with an exception in JAXRSUtils.java line 1000 or so. Changing Root#hello's signature to:

      @Path("hello")
      public HelloResource hello(@SuppressWarnings("unused") @BeanParam Bean param) {
      }

      makes the exception go away and has the Bean injected into HelloResource.

      In my opinion this should not be necessary, and indeed, Jersey and RestEasy both work support this construct without having to resort to introducing unused parameters.

      I've attached a quickstart that shows the problem.

      Attachments

        1. cxf-5214.zip
          11 kB
          Martijn Dashorst

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            dashorst Martijn Dashorst
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: