Comments (10)
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.
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.
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.
I'm also interested in getting this working with more recent versions of Dropwizard.
from dropwizard-guice.
Please do that
from dropwizard-guice.
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.
@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.
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.
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.
I just pushed release 1.0.0 that uses dropwizard 1.0.0
from dropwizard-guice.
Related Issues (20)
- Can not register jersey client in guice
- Binding annotations on providers don't seem to work HOT 1
- AutoConfig should ignore anonymous class HOT 1
- Dropwizard Not Starting Due to HK2 Failure HOT 4
- dropwizrd-guice not working with Dropwizard-core 1.1.0
- LinkageError ... attempted duplicate class definition for name: "org/glassfish/hk2/api/ServiceLocatorState"
- jersey2-guice is defunct HOT 1
- Are there plans to add DropWizard 1.0.0 support? HOT 5
- No License inside Jar file HOT 4
- Getting a warning at startup: "It appears jersey2-guice-spi is either not present or in conflict with some other Jar" HOT 14
- com.google.inject.OutOfScopeException on inject javax.servlet.http.HttpServletRequest HOT 11
- Binding annotations aren't being consistently honored HOT 3
- Integration Test using mocked beans HOT 1
- @BeanParam + @QueryParam don't work with Dropwizard-guice HOT 6
- when i add a filter to jersey , then Jersey error HOT 5
- Compatiblity with Dropwizard 1.0? HOT 27
- AutoConfig not honouring Guice Singleton annotation on resource classes HOT 1
- How exactly HelloWorldConfiguration and Environment get injected in the example HOT 1
- Deprecated API WARNing in v1.0.0.2 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropwizard-guice.