GithubHelp home page GithubHelp logo

Comments (10)

pukkaone avatar pukkaone commented on August 24, 2024

To work around the dependency conflicts, I excluded the obsolete Dropwizard dependencies pulled in by Dropwizard-Guice 0.8.4.0:

  <dependency>
    <groupId>com.hubspot.dropwizard</groupId>
    <artifactId>dropwizard-guice</artifactId>
    <version>0.8.4.0</version>
    <exclusions>
      <exclusion>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-core</artifactId>
      </exclusion>
      <exclusion>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-jackson</artifactId>
      </exclusion>
      <exclusion>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-jersey</artifactId>
      </exclusion>
      <exclusion>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-jetty</artifactId>
      </exclusion>
      <exclusion>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-lifecycle</artifactId>
      </exclusion>
      <exclusion>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-servlets</artifactId>
      </exclusion>
    </exclusions>
  </dependency>

from dropwizard-guice.

phavelar avatar phavelar commented on August 24, 2024

also would like dropwizard 0.9.2 support. The exclusions above are not sufficient or do not work when using maven enforcer plugin.

Dependency convergence error for com.google.code.findbugs:annotations:3.0.0 paths to dependency are:
+-com.hubspot.dropwizard:dropwizard-guice:0.8.4.0
+-com.google.code.findbugs:annotations:3.0.0
and
+-com.hubspot.dropwizard:dropwizard-guice:0.8.4.0
+-org.reflections:reflections:0.9.9
+-com.google.code.findbugs:annotations:2.0.1

[WARNING]
Dependency convergence error for org.javassist:javassist:3.18.1-GA paths to dependency are:
+-com.hubspot.dropwizard:dropwizard-guice:0.8.4.0
+-org.glassfish.jersey.core:jersey-server:2.22.1
+-org.glassfish.hk2:hk2-locator:2.4.0-b31
+-org.javassist:javassist:3.18.1-GA
and
+-com.hubspot.dropwizard:dropwizard-guice:0.8.4.0
+-org.reflections:reflections:0.9.9
+-org.javassist:javassist:3.18.2-GA

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for com.google.code.findbugs:annotations:3.0.0 paths to dependency are:

+-com.hubspot.dropwizard:dropwizard-guice:0.8.4.0
+-com.google.code.findbugs:annotations:3.0.0
and

+-com.hubspot.dropwizard:dropwizard-guice:0.8.4.0
+-org.reflections:reflections:0.9.9
+-com.google.code.findbugs:annotations:2.0.1
,
Dependency convergence error for org.javassist:javassist:3.18.1-GA paths to dependency are:

+-com.hubspot.dropwizard:dropwizard-guice:0.8.4.0
+-org.glassfish.jersey.core:jersey-server:2.22.1
+-org.glassfish.hk2:hk2-locator:2.4.0-b31
+-org.javassist:javassist:3.18.1-GA
and

+-com.hubspot.dropwizard:dropwizard-guice:0.8.4.0
+-org.reflections:reflections:0.9.9
+-org.javassist:javassist:3.18.2-GA

from dropwizard-guice.

jarrodhroberson avatar jarrodhroberson commented on August 24, 2024

I took a shot at this and could not get it to compile.

com.google.inject.CreationException: Unable to create injector, see the following errors:

1) Error injecting constructor, java.lang.IllegalStateException: java.lang.NoSuchFieldException: defaultGenerator
  at com.hubspot.dropwizard.guice.HK2Linker.<init>(HK2Linker.java:17)
  at com.hubspot.dropwizard.guice.JerseyModule.configureServlets(JerseyModule.java:23)
  while locating com.hubspot.dropwizard.guice.HK2Linker

do not know enough about Jersey to get it to work, I use RestEasy outside Dropwizard.

from dropwizard-guice.

stantonk avatar stantonk commented on August 24, 2024

I'm also interested in getting this working with more recent versions of Dropwizard.

from dropwizard-guice.

manusovich avatar manusovich commented on August 24, 2024

Please do that

from dropwizard-guice.

scho avatar scho commented on August 24, 2024

We are currently using dropwizard-guice-0.8.4 together with dropizward-0.9.2.
In order to do so we set the following dependency management:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.dropwizard</groupId>
      <artifactId>dropwizard-jetty</artifactId>
      <version>0.9.2</version>
    </dependency>
    <dependency>
      <groupId>io.dropwizard</groupId>
      <artifactId>dropwizard-jackson</artifactId>
      <version>0.9.2</version>
    </dependency>
    <dependency>
      <groupId>io.dropwizard</groupId>
      <artifactId>dropwizard-jersey</artifactId>
      <version>0.9.2</version>
    </dependency>
    <dependency>
      <groupId>io.dropwizard</groupId>
      <artifactId>dropwizard-servlets</artifactId>
      <version>0.9.2</version>
    </dependency>
    <dependency>
      <groupId>io.dropwizard</groupId>
      <artifactId>dropwizard-lifecycle</artifactId>
      <version>0.9.2</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.hk2</groupId>
      <artifactId>hk2-api</artifactId>
      <version>2.4.0-b31</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.hk2</groupId>
      <artifactId>hk2-locator</artifactId>
      <version>2.4.0-b31</version>
    </dependency>
    <dependency>
      <groupId>io.dropwizard.metrics</groupId>
      <artifactId>metrics-healthchecks</artifactId>
      <version>3.1.2</version>
    </dependency>
    <dependency>
      <groupId>org.reflections</groupId>
      <artifactId>reflections</artifactId>
      <version>0.9.9</version>
    </dependency>
  </dependencies>
</dependencyManagement>

from dropwizard-guice.

infprime avatar infprime commented on August 24, 2024

@phavelar I am working around those dependency conflicts by using the following additional exclusions :

<exclusion>
    <groupId>com.google.code.findbugs</groupId>
    <artifactId>annotations</artifactId>
</exclusion>
<exclusion>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
</exclusion>

Also, it would be amazing see support for Dropwizard 1.0.0 . It is currently not possible I believe because DW 1.0.0 has upgraded to Jersey 2.22.2, while dropwizard-guice still uses 2.22.1 ( and causes a conflict on hk2-api:jar:2.4.0-b34 and hk2-api:jar:2.4.0-b31 versions respectively. A simple exclusion rule here doesn't seem to work and results in the same exception mentioned by @jarrodhroberson above)

from dropwizard-guice.

derekbassett avatar derekbassett commented on August 24, 2024

Off Topic
Hey because the documentation on DropWizard site does not explain how to do this. I just generated a gist that explains how to use Jersey's own DI in your application. As an alternative to Guice as your dependency management framework. https://gist.github.com/derekbassett/712698cd6424e5ff04da

from dropwizard-guice.

infprime avatar infprime commented on August 24, 2024

I looked some more into this. The library https://github.com/Squarespace/jersey2-guice#getting-started, on which dropwizard-guice is based, explicitly warns that the startup may not be reliable:

Jersey/HK2 uses unfortunately SPIs and the Singleton pattern internally. Your code is effectively racing against the Servlet container's code and the first one to initialize HK2's ServiceLocatorGenerator inside its ServiceLocatorFactory wins.

This library uses two approaches to override HK2's own ServiceLocatorGenerator. It first tries to use a SPI and if it can't it'll fall back to reflection to replace a private static field. Regardless of the approach it's still a race against the Servlet container.

I believe they are referring to this method here : https://github.com/Squarespace/jersey2-guice/blob/master/jersey2-guice-impl/src/main/java/com/squarespace/jersey2/guice/JerseyGuiceUtils.java#L117

I tried making the following upgrades to dropwizard-guice

  • Dropwizard 1.0.0-SNAPSHOT (from 0.8.4)
  • jersey2-guice 1.0.6 (from 0.10)
  • jersey-server 2.22.2 (from 2.21)
  • hk2-api 2.4.0-b34 (from 2.4.0-b31)

(I've added the maven-enforcer plugin to ensure there's no DependencyConvergence errors)
All but 1 test pass (the failed test is https://github.com/HubSpot/dropwizard-guice/blob/4d079c98f026498ebc94e8514bd647b4c2c31f08/src/test/java/com/hubspot/dropwizard/guice/InjectedIntegrationTest.java). I'm unable to debug any further because of my limited knowledge of the Jersey and HK2 internals.

The changes are here : https://github.com/bladecatcher/dropwizard-guice

Having said that, the folks at https://github.com/gwizard/gwizard/tree/master/gwizard-jersey have this to say about jersey2-guice:

... because Jersey v2 and Guice do not play nice together. The courageous souls at Squarespace managed to create an adaptor, but it works by using reflection to punch values into private static final member data in Jersey. This module uses that adaptor; it works for the current version of Jersey, but it may not work for future versions of Jersey.

and they take the RESTEasy route, but obviously that's not an option for anyone using Dropwizard

I'd appreciate it if anyone with more knowledge on this matter can shed more light on the future of this approach.

from dropwizard-guice.

jhaber avatar jhaber commented on August 24, 2024

I just pushed release 1.0.0 that uses dropwizard 1.0.0

from dropwizard-guice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.