jersey
  1. jersey
  2. JERSEY-1271

interface-based resources no longer work

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0-m06
    • Fix Version/s: 2.0-m06, 2.0
    • Component/s: None
    • Labels:
      None

      Description

      Looks like the singletons feature broke interface-based resources. My sample resource, that implements a @Path() annotated interface is now treated as a singleton provider:

      [FATAL] Parameter uriInfo of private javax.ws.rs.core.UriInfo org.glassfish.jersey.examples.sysprops.impl.PropertyNamesResourceImpl.uriInfo cannot be injected into singleton resource.
      [NON-FATAL] A resource, class org.glassfish.jersey.examples.sysprops.impl.PropertyNamesResourceImpl, implements provider interface [interface org.glassfish.jersey.examples.sysprops.PropertyNamesResource] but does not explicitly define the scope (@Singleton, @PerLookup). The resource class will be managed as singleton.
      

      This is how the resource interface looks like:

      @Path("properties")
      @Produces(MediaType.TEXT_PLAIN)
      @Consumes(MediaType.TEXT_PLAIN)
      public interface PropertyNamesResource {
          @GET
          Set<String> getPropertyNames();
      
          @Path("{name}")
          public PropertyResource getProperty(@PathParam("name") String name);
      }
      

      And this is how the implementation looks like:

      public class PropertyNamesResourceImpl implements PropertyNamesResource {
          @Context
          private UriInfo uriInfo;
      
          @Override
          public Set<String> getPropertyNames() {
              return System.getProperties().stringPropertyNames();
          }
      
          @Override
          public PropertyResource getProperty(@PathParam("name") String name) {
              return new PropertyResourceImpl(name, uriInfo);
          }
      }
      

        Activity

        Hide
        Martin Matula added a comment -

        I've managed to work around this by adding org.glassfish.jersey.example package to the list of packages that are not considered as provider packages. Anyway, this needs to be solved better - as we discussed, whitelist for jax-rs packages and using @Contract annotation for non-jax-rs provider interfaces.

        Show
        Martin Matula added a comment - I've managed to work around this by adding org.glassfish.jersey.example package to the list of packages that are not considered as provider packages. Anyway, this needs to be solved better - as we discussed, whitelist for jax-rs packages and using @Contract annotation for non-jax-rs provider interfaces.
        Hide
        Miroslav Fuksa added a comment -

        fixed

        Show
        Miroslav Fuksa added a comment - fixed

          People

          • Assignee:
            Miroslav Fuksa
            Reporter:
            Martin Matula
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 3 hours
              3h