HubSpot / dropwizard-guice

Adds support for Guice to Dropwizard
Apache License 2.0
266 stars 95 forks source link

Under latest guice 4.0-SNAPSHOT: Overriding @Provides method not allowed #32

Closed joshng closed 10 years ago

joshng commented 10 years ago

It appears a policy/validation change introduced in recent guice development (required, btw, for java8 support) is incompatible with an implementation detail in dropwizard-guice.

With the following in my pom.xml:

<properties>
  <java.version>1.8</java.version>
  <guice.version>4.0-SNAPSHOT</guice.version>
  <dropwizard.version>0.7.0</dropwizard.version>

...

<repositories>
  <repository>
    <id>google-snapshots</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>
</repositories>

...

  <dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>${guice.version}</version>
  </dependency>
  <dependency>
    <groupId>com.hubspot.dropwizard</groupId>
    <artifactId>dropwizard-guice</artifactId>
    <version>${dropwizard.version}</version>
  </dependency>

... server fails to start with the following error:

ERROR [2014-08-12 14:54:10,565] com.hubspot.dropwizard.guice.GuiceBundle: Exception occurred when creating Guice Injector - exiting ! com.google.inject.CreationException: Unable to create injector, see the following errors: ! ! 1) Overriding @Provides methods is not allowed. ! @Provides method: com.sun.jersey.guice.JerseyServletModule.webApp() ! overridden by: com.hubspot.dropwizard.guice.JerseyContainerModule.webApp() ! at com.google.inject.internal.ProviderMethodsModule.getProviderMethods(ProviderMethodsModule.java:126)

jhaber commented 10 years ago

I just released version 0.7.1 which should fix this issue, can you give it a try

eliast commented 10 years ago

It works here! :+1: Thanks @HiJon89

joshng commented 10 years ago

:+1: