jersey
  1. jersey
  2. JERSEY-1709

Autodiscovery of providers does not work

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Duplicate
    • Affects Version/s: 2.0-m12
    • Fix Version/s: 2.0-rc1, 2.0
    • Component/s: core
    • Labels:
      None

      Description

      The Spec. Section 2.3.2 says:

      When an Application subclass is present in the archive, if both Application.getClasses and
      Application.getSingletons return an empty list then all root resource classes and providers
      packaged in the web application MUST be included and the JAX-RS implementation is REQUIRED
      to discover them automatically.

      But having:

      public class MyApp extends Application {
      }
      public class StringBean {
      	private String data;
      
      	public String get() {
      		return data;
      	}
      
      	public void set(String data) {
      		this.data = data;
      	}
      	
      	@Override
      	public String toString() {
      		return "StringBean. To get a value, use rather #get() method.";
      	}
      
      	public StringBean(String data) {
      		super();
                      set(data);
      	}
      }
      public class StringBeanParamConverter implements ParamConverter<StringBean> {
      
      	@Override
      	public StringBean fromString(String value) throws IllegalArgumentException {
      		return new StringBean(value);
      	}
      
      	@Override
      	public String toString(StringBean value) throws IllegalArgumentException {
      		return value.get();
      	}
      }
      
      @Provider
      public class StringBeanParamConverterProvider implements ParamConverterProvider {
      	@SuppressWarnings("unchecked")
      	@Override
      	public <T> ParamConverter<T> getConverter(Class<T> rawType,
      			Type genericType, Annotation[] annotations) {
      		if (rawType == StringBean.class)
      			return (ParamConverter<T>) new StringBeanParamConverter();
      		return null;
      	}
      }
      

      The deployment of the war fails with:

      II 06, 2013 6:57:41 ODP. org.glassfish.jersey.server.ApplicationHandler initialize
      INFO: Initiating Jersey application, version Jersey: 2.0-SNAPSHOT 2013-02-06 10:43:08...
      II 06, 2013 6:57:41 ODP. org.glassfish.jersey.internal.Errors processErrors
      SEVERE: The following errors and warnings have been detected:
      WARNING: A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by @Consumes and @Produces annotations at Java methods public synchronized javax.ws.rs.core.Response org.glassfish.jersey.server.wadl.internal.WadlResource.getWadl(javax.ws.rs.core.UriInfo) and public synchronized javax.ws.rs.core.Response org.glassfish.jersey.server.wadl.internal.WadlResource.getWadl(javax.ws.rs.core.UriInfo) at matching regular expression /application\.wadl. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.
      WARNING: A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by @Consumes and @Produces annotations at Java methods public synchronized javax.ws.rs.core.Response org.glassfish.jersey.server.wadl.internal.WadlResource.geExternalGrammar(javax.ws.rs.core.UriInfo,java.lang.String) and public synchronized javax.ws.rs.core.Response org.glassfish.jersey.server.wadl.internal.WadlResource.geExternalGrammar(javax.ws.rs.core.UriInfo,java.lang.String) at matching regular expression /([^/]+?). These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.

        Activity

        Hide
        Michal Gajdos added a comment -

        Should be fixed as a part of JERSEY-1595.

        Show
        Michal Gajdos added a comment - Should be fixed as a part of JERSEY-1595 .

          People

          • Assignee:
            Michal Gajdos
            Reporter:
            jan.supol
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 3 hours
              3h
              Remaining:
              0m
              Logged:
              Time Not Required
              1m