title: Guice configuration error: Could not find a suitable constructor
body: <p>I am using GUICE for dependency injection for a RESTful API build using Dropwizard. This is the error I am getting:</p>
  
  <blockquote>
    <p>com.google.inject.ConfigurationException: Guice configuration errors:</p>
    
    <p>1) Could not find a suitable constructor in
    com.api.analytics.visitor.web.VisitorParams. Classes must have
    either one (and only one) constructor annotated with @Inject or a
    zero-argument constructor that is not private.   at
    com.api.analytics.visitor.web.VisitorParams.class(VisitorParams.java:27)
    while locating com.api.analytics.visitor.web.VisitorParams
        for parameter 0 at com.api.analytics.visitor.web.v1.VisitorResource.(VisitorResource.java:68)
    while locating
    com.api.analytics.visitor.web.v1.VisitorResource</p>
  </blockquote>
  
  <p>Here is how my resource is setup:</p>
  
  <pre><code>package com.api.analytics.visitor.web.v1;
  
  //imports
  
  @Path("/visitor")
  @Produces({MediaType.APPLICATION_JSON, ExtraMediaTypes.PROTOBUF})
  @Consumes(MediaType.APPLICATION_JSON)
  public class VisitorResource {
    private final ContactsManager contactsManager;
    private final ActivityFetcher.Provider activityFetcherProvider;
    private final VisitSourceMapper visitSourceMapper;
    private final TimeZoneClient timeZoneClient;
    private final GatesClient gatesClient;
    private final Value&lt;Integer&gt; smallScanLimit;
    private final Provider&lt;Integer&gt; portalIdProvider;
    private final VisitorParams visitorParams;
  
    @Inject
    public VisitorResource(@Bind({Bind.Params.QUERY}) VisitorParams visitorParams,
                           ContactsManager contactsManager,
                           ActivityFetcher.Provider activityFetcherProvider,
                           VisitSourceMapper visitSourceMapper,
                           TimeZoneClient timeZoneClient,
                           GatesClient gatesClient,
                           @Named("analytics.activities.fetch.small.scan.limit") Value&lt;Integer&gt; smallScanLimit,
                           @StashedHubId Provider&lt;Integer&gt; portalIdProvider) {
      this.contactsManager = contactsManager;
      this.activityFetcherProvider = activityFetcherProvider;
      this.visitSourceMapper = visitSourceMapper;
      this.timeZoneClient = timeZoneClient;
      this.gatesClient = gatesClient;
      this.smallScanLimit = smallScanLimit;
      this.portalIdProvider = portalIdProvider;
      this.visitorParams = visitorParams;
    }
  
    @Timed
    @GET
    @Path("/{identity}/activities")
    public List&lt;Activity&gt; getActivitiesGet(@PathParam("identity") String identity) throws Exception {
      return getActivities(identity);
    }
  
    //other methods
  }
  </code></pre>
  
  <p>Here is my <code>VisitorParams</code> class:</p>
  
  <pre><code>package com.api.analytics.visitor.web;
  
  //imports
  
  public class VisitorParams {
    private final Optional&lt;Long&gt; start;
    private final Optional&lt;Long&gt; end;
    private final Set&lt;ActivityType&gt; activityTypes;
    private final Optional&lt;Integer&gt; limit;
    private final boolean reversed;
    private final Set&lt;Long&gt; vids;
  
    @JsonCreator
    public VisitorParams (@JsonProperty("start") Optional&lt;Long&gt; start,
                          @JsonProperty("end") Optional&lt;Long&gt; end,
                          @JsonProperty("type") Optional&lt;Set&lt;ActivityType&gt;&gt; activityTypes,
                          @JsonProperty("limit") Optional&lt;Integer&gt; limit,
                          @JsonProperty("reversed") @DefaultValue("false") boolean reversed,
                          @JsonProperty("vid") Optional&lt;Set&lt;Long&gt;&gt; vids) {
      this.start = start;
      this.end = end;
      this.activityTypes = activityTypes.or(Collections.emptySet());
      this.limit = limit;
      this.reversed = reversed;
      this.vids = vids.or(Collections.emptySet());
    }
  
    public Optional&lt;Long&gt; getStart() {
      return this.start;
    }
  
    //other getters
  }
  </code></pre>
  
  <p>One thing I did try was adding a constructor in my <code>VisitorParams</code> class like this:</p>
  
  <pre><code>public VisitorParams () {}
  </code></pre>
  
  <p>When I did that, I get errors about how some variables might not have been initialized.</p>
  
  <p>So what am I doing wrong here to cause this configuration error? I'm pretty new to using Guice and Dropwizard, so let me know if you need any other information. Thanks!</p>