Comments (27)
+1 to find a solution to this issue.
from dropwizard-guice.
I'll be following up with jersey2-guice maintainers to see if we can get this fixed on their end. In the meantime you should be able to work around this by adding something like this to your tests:
@BeforeClass
public void ensureServiceLocatorPopulated() {
JerseyGuiceUtils.reset();
}
from dropwizard-guice.
I am getting java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.BuilderHelper.getRank
with dropwizard 1.0.4 and dropwizard-guice 1.0.0
from dropwizard-guice.
I am not sure if this helps, but I had a similar issue with classes using ResourceTestRule
I was able to solve by running a test containing DropwizardAppRule
before running any other tests. I put the following alphabetically first in the test suite and the problems are away. It also works with 1.0.0.2
public class GuiceCompatibilityTest {
@ClassRule
public static DropwizardAppRule<FleetServiceConfiguration> rule = new DropwizardAppRule<>(
TestApplication.class,
TestApplication.getConfigFilepath()
);
@Test
public void testBlank() {
assertTrue(true);
}
@After
public void tearDown() throws Exception {
JerseyGuiceUtils.reset();
}
}
from dropwizard-guice.
@panghy can you tell me exactly what you did to make dw-guice run with dw 1.1.0? I'm getting a
org.jvnet.hk2.internal.DynamicConfigurationImpl.addIdempotentFilter([Lorg/glassfish/hk2/api/Filter;)V
WARN [2017-04-06 10:22:32,665] org.eclipse.jetty.util.component.AbstractLifeCycle: FAILED org.eclipse.jetty.server.Server@1533338c: java.lang.AbstractMethodError: org.jvnet.hk2.internal.DynamicConfigurationImpl.addIdempotentFilter([Lorg/glassfish/hk2/api/Filter;)V
! java.lang.AbstractMethodError: org.jvnet.hk2.internal.DynamicConfigurationImpl.addIdempotentFilter([Lorg/glassfish/hk2/api/Filter;)V
error...
from dropwizard-guice.
I ran into the same issue, but I didn't want to run a DropwizardAppRule. Not only does that feel more like an integration test to me, but it also takes a lot longer to initialize.
So, I decided to write a junit rule to connect a guice injector to jersey, following the code used in the GuiceBundle class.
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.extension.ServiceLocatorGenerator;
import org.junit.rules.ExternalResource;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Stage;
import com.google.inject.servlet.ServletModule;
import com.squarespace.jersey2.guice.JerseyGuiceModule;
import com.squarespace.jersey2.guice.JerseyGuiceUtils;
/**
* Code copied from {@link com.hubspot.dropwizard.guice.GuiceBundle}
* to create a guice injector for jersey2 for unit testing.
*/
public class JerseyGuiceRule extends ExternalResource {
@Override
protected void before() throws Throwable {
Injector baseInjector = Guice.createInjector(Stage.TOOL, new ServletModule());
JerseyGuiceUtils.install(new ServiceLocatorGenerator() {
@Override
public ServiceLocator create(String name, ServiceLocator parent) {
if (!name.startsWith("__HK2_Generated_")) {
return null;
}
return baseInjector.createChildInjector(new JerseyGuiceModule(name))
.getInstance(ServiceLocator.class);
}
});
}
@Override
protected void after() {
JerseyGuiceUtils.reset();
}
}
To use in your test class, simply create a class rule:
import static org.junit.Assert.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.junit.ClassRule;
import org.junit.Test;
public class JerseyTest {
@ClassRule
public static JerseyGuiceRule rule = new JerseyGuiceRule();
@Test
public void testJersey() {
Response response = Response.status(Status.BAD_REQUEST).build();
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
}
}
from dropwizard-guice.
Unfortunately this appears to be a side effect of the fix for #88
With the old dependency order there would be a warning on startup:
com.squarespace.jersey2.guice.JerseyGuiceUtils: It appears jersey2-guice-spi is either not present or in conflict with some other Jar: ServiceLocatorGeneratorImpl(hk2-locator, 814377348)
With the new dependency order this warning is gone, but it means that you won't be able to use any Jersey classes (including the client) without first populating the GuiceServiceLocatorGeneratorStub
.
I see the following options to fix:
- Revert 5b2e335 which will unfix #88
- Update jersey2-guice to handle the case of an empty
GuiceServiceLocatorGeneratorStub
- Add a helper to initialize the necessary state for testing and publish in a test-jar
from dropwizard-guice.
I'm using 1.0.0.2 with Dropwizard 1.0.5 and I'm seeing both the warning #88 tries to fix and the error this issue describes:
09:57:00.958 INFO : HV000001: Hibernate Validator 5.2.4.Final | org.hibernate.validator.internal.util.Version {} main
WARN [2016-12-23 09:57:01,142] com.netflix.governator.lifecycle.ClasspathScanner: No base packages specified - no classpath scanning will be done
WARN [2016-12-23 09:57:01,933] com.squarespace.jersey2.guice.JerseyGuiceUtils: It appears jersey2-guice-spi is either not present or in conflict with some other Jar: ServiceLocatorGeneratorImpl(hk2-locator, 1010156357)
Exception in thread "main" java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.BuilderHelper.getRank(Ljava/lang/Class;)I
at org.jvnet.hk2.internal.Utilities.createAutoDescriptor(Utilities.java:723)
at org.jvnet.hk2.internal.DynamicConfigurationImpl.addActiveDescriptor(DynamicConfigurationImpl.java:196)
at com.squarespace.jersey2.guice.JerseyGuiceUtils.link(JerseyGuiceUtils.java:319)
at com.squarespace.jersey2.guice.JerseyGuiceUtils.link(JerseyGuiceUtils.java:287)
at com.squarespace.jersey2.guice.JerseyGuiceModule$ServiceLocatorProvider.get(JerseyGuiceModule.java:111)
at com.squarespace.jersey2.guice.JerseyGuiceModule$ServiceLocatorProvider.get(JerseyGuiceModule.java:96)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:53)
at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:65)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
at com.netflix.governator.LifecycleListenerModule$LifecycleListenerProvisionListener.onProvision(LifecycleListenerModule.java:51)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
at com.netflix.governator.guice.InternalLifecycleModule.onProvision(InternalLifecycleModule.java:65)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)
at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:232)
at com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:236)
at com.hubspot.dropwizard.guice.GuiceBundle.getInjector(GuiceBundle.java:147)
at au.com.vitagroup.oms.OmsApplication.initialize(OmsApplication.java:37)
at io.dropwizard.Application.run(Application.java:74)
at au.com.vitagroup.oms.OmsApplication.main(OmsApplication.java:21)
Reverting to 1.0.0.1 doesn't help. Reverting Dropwizard to 1.0.4 doesn't help. Going down to 1.0.3 does, even with dropwizard-guice version 1.0.0.2. I'm still seeing the warning from #88, though.
from dropwizard-guice.
I haven't seen this exception before, can you supply a runnable code sample that reproduces the issue? Also, can you make sure you're running version 1.0.0.2 of dropwizard-guice
from dropwizard-guice.
I'm definitely on 1.0.0.2:
+--- com.hubspot.dropwizard:dropwizard-guice:1.0+ -> 1.0.0.2
The failing unit test is for a core element in our classes and tied in with everything. I'd have to spend a while crafting something from scratch.
Here's more context on the error though, maybe that'll help. It's when using jaxws UriBuilder.
java.lang.RuntimeException: java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.IllegalStateException: It appears there is no ServiceLocatorGenerator installed.
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:152)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:95)
at javax.ws.rs.core.UriBuilder.fromPath(UriBuilder.java:148)
at com.flightstats.flex.common.customer.CustomerConfigHubRepositoryTest.testFetch(CustomerConfigHubRepositoryTest.java:32)
Caused by:
java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.IllegalStateException: It appears there is no ServiceLocatorGenerator installed.
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:122)
at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:225)
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:135)
... 4 more
Caused by:
java.lang.IllegalStateException: It appears there is no ServiceLocatorGenerator installed.
at com.squarespace.jersey2.guice.GuiceServiceLocatorGeneratorStub.create(GuiceServiceLocatorGeneratorStub.java:50)
at org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.internalCreate(ServiceLocatorFactoryImpl.java:312)
at org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.create(ServiceLocatorFactoryImpl.java:293)
at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:109)
at org.glassfish.jersey.internal.RuntimeDelegateImpl.<init>(RuntimeDelegateImpl.java:63)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:118)
from dropwizard-guice.
Well, it's something classpath related, not code related. Even this tiny test has the same a failure:
@Test
public void testFoo() {
UriBuilder.fromPath("http://foo");
}
Maybe I need to specifically exclude a library or a transitive dependency?
I changed only these dependencies to point the latest version of each:
compile group: 'io.dropwizard', name: 'dropwizard-client', version: '1.0+'
compile group: 'io.dropwizard', name: 'dropwizard-testing', version: '1.0+'
compile group: 'io.dropwizard', name: 'dropwizard-assets', version: '1.0+'
compile group: 'io.dropwizard', name: 'dropwizard-core', version: '1.0+'
compile group: 'io.dropwizard', name: 'dropwizard-views', version: '1.0+'
compile group: 'io.dropwizard', name: 'dropwizard-metrics', version: '1.0+'
compile group: 'io.dropwizard', name: 'dropwizard-metrics-graphite', version: '1.0+'
compile group: 'io.dropwizard', name: 'dropwizard-servlets', version: '1.0+'
compile group: 'io.dropwizard', name: 'dropwizard-views-mustache', version: '1.0+'
compile group: 'com.google.inject.extensions', name: 'guice-throwingproviders', version: '3+'
compile group: 'com.github.roskart.dropwizard-jaxws', name: 'dropwizard-jaxws', version: '1.0+'
compile group: 'com.hubspot.dropwizard', name: 'dropwizard-guice', version: '1.0+'
compile group: 'com.yunspace.dropwizard', name: 'dropwizard-xml', version: '41'
Here is the "gradle dependencies" output:
testRuntime - Runtime dependencies for source set 'test'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.0.0
| \--- org.jetbrains.kotlin:kotlin-runtime:1.0.0
+--- com.fasterxml.jackson.module:jackson-module-jsonSchema:2.7.0
+--- com.github.roskart.dropwizard-jaxws:dropwizard-jaxws:1.0+ -> 1.0.0
| +--- org.apache.cxf:cxf-rt-frontend-jaxws:3.1.6
| | +--- xml-resolver:xml-resolver:1.2
| | +--- org.ow2.asm:asm:5.0.4
| | +--- org.apache.cxf:cxf-core:3.1.6
| | | +--- org.codehaus.woodstox:woodstox-core-asl:4.4.1
| | | | \--- org.codehaus.woodstox:stax2-api:3.1.4
| | | \--- org.apache.ws.xmlschema:xmlschema-core:2.2.1
| | +--- org.apache.cxf:cxf-rt-bindings-soap:3.1.6
| | | +--- org.apache.cxf:cxf-core:3.1.6 (*)
| | | +--- org.apache.cxf:cxf-rt-wsdl:3.1.6
| | | | +--- org.apache.cxf:cxf-core:3.1.6 (*)
| | | | +--- wsdl4j:wsdl4j:1.6.3
| | | | \--- org.ow2.asm:asm:5.0.4
| | | \--- org.apache.cxf:cxf-rt-databinding-jaxb:3.1.6
| | | +--- org.apache.cxf:cxf-core:3.1.6 (*)
| | | +--- org.apache.cxf:cxf-rt-wsdl:3.1.6 (*)
| | | +--- com.sun.xml.bind:jaxb-impl:2.2.11
| | | \--- com.sun.xml.bind:jaxb-core:2.2.11
| | +--- org.apache.cxf:cxf-rt-bindings-xml:3.1.6
| | | \--- org.apache.cxf:cxf-core:3.1.6 (*)
| | +--- org.apache.cxf:cxf-rt-frontend-simple:3.1.6
| | | +--- org.apache.cxf:cxf-core:3.1.6 (*)
| | | +--- org.apache.cxf:cxf-rt-bindings-soap:3.1.6 (*)
| | | \--- org.apache.cxf:cxf-rt-wsdl:3.1.6 (*)
| | \--- org.apache.cxf:cxf-rt-ws-addr:3.1.6
| | +--- org.apache.cxf:cxf-core:3.1.6 (*)
| | +--- org.apache.cxf:cxf-rt-bindings-soap:3.1.6 (*)
| | \--- org.apache.cxf:cxf-rt-ws-policy:3.1.6
| | +--- wsdl4j:wsdl4j:1.6.3
| | +--- org.apache.cxf:cxf-core:3.1.6 (*)
| | \--- org.apache.neethi:neethi:3.0.3
| \--- org.apache.cxf:cxf-rt-transports-http:3.1.6
| \--- org.apache.cxf:cxf-core:3.1.6 (*)
+--- com.hubspot.dropwizard:dropwizard-guice:1.0+ -> 1.0.0.2
| +--- com.squarespace.jersey2-guice:jersey2-guice-impl:1.0.6
| | +--- com.google.inject.extensions:guice-multibindings:4.0
| | | \--- com.google.inject:guice:4.0 -> 4.1.0
| | | +--- javax.inject:javax.inject:1
| | | +--- aopalliance:aopalliance:1.0
| | | \--- com.google.guava:guava:19.0
| | +--- com.google.inject.extensions:guice-servlet:4.0
| | | \--- com.google.inject:guice:4.0 -> 4.1.0 (*)
| | +--- org.glassfish.jersey.containers:jersey-container-servlet-core:2.22.2 -> 2.23.1
| | | +--- org.glassfish.hk2.external:javax.inject:2.4.0-b34
| | | +--- org.glassfish.jersey.core:jersey-common:2.23.1
| | | | +--- javax.ws.rs:javax.ws.rs-api:2.0.1
| | | | +--- javax.annotation:javax.annotation-api:1.2
| | | | +--- org.glassfish.jersey.bundles.repackaged:jersey-guava:2.23.1
| | | | +--- org.glassfish.hk2:hk2-api:2.4.0-b34
| | | | | +--- javax.inject:javax.inject:1
| | | | | +--- org.glassfish.hk2:hk2-utils:2.4.0-b34
| | | | | | \--- javax.inject:javax.inject:1
| | | | | \--- org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34
| | | | +--- org.glassfish.hk2.external:javax.inject:2.4.0-b34
| | | | +--- org.glassfish.hk2:hk2-locator:2.4.0-b34
| | | | | +--- org.glassfish.hk2.external:javax.inject:2.4.0-b34
| | | | | +--- org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34
| | | | | +--- org.glassfish.hk2:hk2-api:2.4.0-b34 (*)
| | | | | +--- org.glassfish.hk2:hk2-utils:2.4.0-b34 (*)
| | | | | \--- org.javassist:javassist:3.18.1-GA -> 3.18.2-GA
| | | | \--- org.glassfish.hk2:osgi-resource-locator:1.0.1
| | | +--- org.glassfish.jersey.core:jersey-server:2.23.1
| | | | +--- org.glassfish.jersey.core:jersey-common:2.23.1 (*)
| | | | +--- org.glassfish.jersey.core:jersey-client:2.23.1
| | | | | +--- javax.ws.rs:javax.ws.rs-api:2.0.1
| | | | | +--- org.glassfish.jersey.core:jersey-common:2.23.1 (*)
| | | | | +--- org.glassfish.hk2:hk2-api:2.4.0-b34 (*)
| | | | | +--- org.glassfish.hk2.external:javax.inject:2.4.0-b34
| | | | | \--- org.glassfish.hk2:hk2-locator:2.4.0-b34 (*)
| | | | +--- javax.ws.rs:javax.ws.rs-api:2.0.1
| | | | +--- org.glassfish.jersey.media:jersey-media-jaxb:2.23.1
| | | | | +--- org.glassfish.jersey.core:jersey-common:2.23.1 (*)
| | | | | +--- org.glassfish.hk2:hk2-api:2.4.0-b34 (*)
| | | | | +--- org.glassfish.hk2.external:javax.inject:2.4.0-b34
| | | | | +--- org.glassfish.hk2:hk2-locator:2.4.0-b34 (*)
| | | | | \--- org.glassfish.hk2:osgi-resource-locator:1.0.1
| | | | +--- javax.annotation:javax.annotation-api:1.2
| | | | +--- org.glassfish.hk2:hk2-api:2.4.0-b34 (*)
| | | | +--- org.glassfish.hk2.external:javax.inject:2.4.0-b34
| | | | +--- org.glassfish.hk2:hk2-locator:2.4.0-b34 (*)
| | | | \--- javax.validation:validation-api:1.1.0.Final
| | | \--- javax.ws.rs:javax.ws.rs-api:2.0.1
| | +--- com.squarespace.jersey2-guice:0-jersey2-guice-spi:1.0.6
| | | \--- org.glassfish.hk2:hk2-api:2.4.0-b34 (*)
| | +--- com.google.code.findbugs:jsr305:3.0.1
| | \--- org.slf4j:slf4j-api:1.7.16 -> 1.7.21
| +--- com.google.code.findbugs:annotations:3.0.1
| | +--- net.jcip:jcip-annotations:1.0
| | \--- com.google.code.findbugs:jsr305:3.0.1
| +--- io.dropwizard:dropwizard-core:1.0.0 -> 1.0.2
| | +--- io.dropwizard:dropwizard-util:1.0.2
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.6
| | | +--- com.google.guava:guava:19.0
| | | +--- com.google.code.findbugs:jsr305:3.0.1
| | | \--- joda-time:joda-time:2.9.4
| | +--- io.dropwizard:dropwizard-jackson:1.0.2
| | | +--- com.google.guava:guava:19.0
| | | +--- io.dropwizard:dropwizard-util:1.0.2 (*)
| | | +--- com.fasterxml.jackson.core:jackson-core:2.7.6
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.6
| | | +--- com.fasterxml.jackson.core:jackson-databind:2.7.6
| | | | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.0 -> 2.7.6
| | | | \--- com.fasterxml.jackson.core:jackson-core:2.7.6
| | | +--- com.fasterxml.jackson.datatype:jackson-datatype-guava:2.7.6
| | | | +--- com.fasterxml.jackson.core:jackson-databind:2.7.6 (*)
| | | | \--- com.fasterxml.jackson.core:jackson-core:2.7.6
| | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.7.6
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.7.6
| | | | \--- com.fasterxml.jackson.core:jackson-databind:2.7.6 (*)
| | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.7.6
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.7.6
| | | | \--- com.fasterxml.jackson.core:jackson-databind:2.7.6 (*)
| | | +--- com.fasterxml.jackson.module:jackson-module-afterburner:2.7.6
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.7.6
| | | | \--- com.fasterxml.jackson.core:jackson-databind:2.7.6 (*)
| | | +--- com.fasterxml.jackson.datatype:jackson-datatype-joda:2.7.6
| | | | +--- com.fasterxml.jackson.core:jackson-annotations:2.7.0 -> 2.7.6
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.7.6
| | | | \--- com.fasterxml.jackson.core:jackson-databind:2.7.6 (*)
| | | +--- org.slf4j:slf4j-api:1.7.21
| | | \--- ch.qos.logback:logback-classic:1.1.7
| | | \--- ch.qos.logback:logback-core:1.1.7
| | +--- io.dropwizard:dropwizard-validation:1.0.2
| | | +--- io.dropwizard:dropwizard-util:1.0.2 (*)
| | | +--- org.hibernate:hibernate-validator:5.2.4.Final
| | | | +--- javax.validation:validation-api:1.1.0.Final
| | | | +--- org.jboss.logging:jboss-logging:3.2.1.Final
| | | | \--- com.fasterxml:classmate:1.1.0
| | | \--- org.glassfish:javax.el:3.0.0
| | +--- io.dropwizard:dropwizard-configuration:1.0.2
| | | +--- io.dropwizard:dropwizard-jackson:1.0.2 (*)
| | | +--- io.dropwizard:dropwizard-validation:1.0.2 (*)
| | | +--- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.7.6
| | | | +--- com.fasterxml.jackson.core:jackson-core:2.7.6
| | | | \--- org.yaml:snakeyaml:1.15
| | | \--- org.apache.commons:commons-lang3:3.4
| | +--- io.dropwizard:dropwizard-logging:1.0.2
| | | +--- io.dropwizard:dropwizard-jackson:1.0.2 (*)
| | | +--- io.dropwizard:dropwizard-validation:1.0.2 (*)
| | | +--- io.dropwizard.metrics:metrics-logback:3.1.2
| | | | \--- io.dropwizard.metrics:metrics-core:3.1.2
| | | | \--- org.slf4j:slf4j-api:1.7.7 -> 1.7.21
| | | +--- org.slf4j:slf4j-api:1.7.21
| | | +--- org.slf4j:jul-to-slf4j:1.7.21
| | | | \--- org.slf4j:slf4j-api:1.7.21
| | | +--- ch.qos.logback:logback-core:1.1.7
| | | +--- ch.qos.logback:logback-classic:1.1.7 (*)
| | | +--- org.slf4j:log4j-over-slf4j:1.7.21
| | | | \--- org.slf4j:slf4j-api:1.7.21
| | | +--- org.slf4j:jcl-over-slf4j:1.7.21
| | | | \--- org.slf4j:slf4j-api:1.7.21
| | | \--- org.eclipse.jetty:jetty-util:9.3.9.v20160517
| | +--- io.dropwizard:dropwizard-metrics:1.0.2
| | | +--- io.dropwizard:dropwizard-lifecycle:1.0.2
| | | | +--- org.slf4j:slf4j-api:1.7.21
| | | | +--- com.google.guava:guava:19.0
| | | | +--- org.eclipse.jetty:jetty-server:9.3.9.v20160517
| | | | | +--- javax.servlet:javax.servlet-api:3.1.0
| | | | | +--- org.eclipse.jetty:jetty-http:9.3.9.v20160517
| | | | | | \--- org.eclipse.jetty:jetty-util:9.3.9.v20160517
| | | | | \--- org.eclipse.jetty:jetty-io:9.3.9.v20160517
| | | | | \--- org.eclipse.jetty:jetty-util:9.3.9.v20160517
| | | | \--- io.dropwizard:dropwizard-util:1.0.2 (*)
| | | +--- io.dropwizard:dropwizard-jackson:1.0.2 (*)
| | | +--- io.dropwizard:dropwizard-validation:1.0.2 (*)
| | | +--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| | | \--- org.slf4j:slf4j-api:1.7.21
| | +--- io.dropwizard:dropwizard-jersey:1.0.2
| | | +--- io.dropwizard:dropwizard-jackson:1.0.2 (*)
| | | +--- io.dropwizard:dropwizard-validation:1.0.2 (*)
| | | +--- io.dropwizard:dropwizard-logging:1.0.2 (*)
| | | +--- org.glassfish.jersey.core:jersey-server:2.23.1 (*)
| | | +--- org.glassfish.jersey.ext:jersey-metainf-services:2.23.1
| | | | +--- org.glassfish.jersey.core:jersey-common:2.23.1 (*)
| | | | \--- javax.ws.rs:javax.ws.rs-api:2.0.1
| | | +--- org.glassfish.jersey.ext:jersey-bean-validation:2.23.1
| | | | +--- org.glassfish.hk2.external:javax.inject:2.4.0-b34
| | | | +--- org.glassfish.jersey.core:jersey-common:2.23.1 (*)
| | | | +--- org.glassfish.jersey.core:jersey-server:2.23.1 (*)
| | | | +--- javax.validation:validation-api:1.1.0.Final
| | | | \--- javax.ws.rs:javax.ws.rs-api:2.0.1
| | | +--- io.dropwizard.metrics:metrics-jersey2:3.1.2
| | | | +--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| | | | \--- io.dropwizard.metrics:metrics-annotation:3.1.2
| | | | \--- org.slf4j:slf4j-api:1.7.7 -> 1.7.21
| | | +--- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.7.6
| | | | +--- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.7.6
| | | | \--- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.7.6
| | | | \--- com.fasterxml.jackson.core:jackson-annotations:2.7.0 -> 2.7.6
| | | +--- org.glassfish.jersey.containers:jersey-container-servlet:2.23.1
| | | | +--- org.glassfish.jersey.containers:jersey-container-servlet-core:2.23.1 (*)
| | | | +--- org.glassfish.jersey.core:jersey-common:2.23.1 (*)
| | | | +--- org.glassfish.jersey.core:jersey-server:2.23.1 (*)
| | | | \--- javax.ws.rs:javax.ws.rs-api:2.0.1
| | | +--- org.eclipse.jetty:jetty-server:9.3.9.v20160517 (*)
| | | +--- org.eclipse.jetty:jetty-webapp:9.3.9.v20160517
| | | | +--- org.eclipse.jetty:jetty-xml:9.3.9.v20160517
| | | | | \--- org.eclipse.jetty:jetty-util:9.3.9.v20160517
| | | | \--- org.eclipse.jetty:jetty-servlet:9.3.9.v20160517
| | | | \--- org.eclipse.jetty:jetty-security:9.3.9.v20160517
| | | | \--- org.eclipse.jetty:jetty-server:9.3.9.v20160517 (*)
| | | +--- org.eclipse.jetty:jetty-continuation:9.3.9.v20160517
| | | \--- org.apache.commons:commons-lang3:3.4
| | +--- io.dropwizard:dropwizard-servlets:1.0.2
| | | +--- org.slf4j:slf4j-api:1.7.21
| | | +--- io.dropwizard:dropwizard-util:1.0.2 (*)
| | | +--- io.dropwizard.metrics:metrics-annotation:3.1.2 (*)
| | | +--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| | | \--- ch.qos.logback:logback-classic:1.1.7 (*)
| | +--- io.dropwizard:dropwizard-jetty:1.0.2
| | | +--- io.dropwizard:dropwizard-logging:1.0.2 (*)
| | | +--- io.dropwizard.metrics:metrics-jetty9:3.1.2
| | | | \--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| | | +--- org.eclipse.jetty:jetty-server:9.3.9.v20160517 (*)
| | | +--- org.eclipse.jetty:jetty-servlet:9.3.9.v20160517 (*)
| | | +--- org.eclipse.jetty:jetty-servlets:9.3.9.v20160517
| | | | +--- org.eclipse.jetty:jetty-continuation:9.3.9.v20160517
| | | | +--- org.eclipse.jetty:jetty-http:9.3.9.v20160517 (*)
| | | | +--- org.eclipse.jetty:jetty-util:9.3.9.v20160517
| | | | \--- org.eclipse.jetty:jetty-io:9.3.9.v20160517 (*)
| | | \--- org.eclipse.jetty:jetty-http:9.3.9.v20160517 (*)
| | +--- io.dropwizard:dropwizard-lifecycle:1.0.2 (*)
| | +--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| | +--- io.dropwizard.metrics:metrics-jvm:3.1.2
| | | \--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| | +--- io.dropwizard.metrics:metrics-servlets:3.1.2
| | | +--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| | | +--- io.dropwizard.metrics:metrics-healthchecks:3.1.2
| | | | \--- org.slf4j:slf4j-api:1.7.7 -> 1.7.21
| | | +--- io.dropwizard.metrics:metrics-json:3.1.2
| | | | \--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| | | \--- io.dropwizard.metrics:metrics-jvm:3.1.2 (*)
| | +--- io.dropwizard.metrics:metrics-healthchecks:3.1.2 (*)
| | +--- io.dropwizard:dropwizard-request-logging:1.0.2
| | | +--- io.dropwizard:dropwizard-jetty:1.0.2 (*)
| | | +--- io.dropwizard:dropwizard-logging:1.0.2 (*)
| | | \--- ch.qos.logback:logback-access:1.1.7
| | | \--- ch.qos.logback:logback-core:1.1.7
| | +--- net.sourceforge.argparse4j:argparse4j:0.7.0
| | \--- org.eclipse.jetty.toolchain.setuid:jetty-setuid-java:1.0.3
| +--- io.dropwizard:dropwizard-jackson:1.0.0 -> 1.0.2 (*)
| +--- io.dropwizard:dropwizard-jersey:1.0.0 -> 1.0.2 (*)
| +--- io.dropwizard:dropwizard-jetty:1.0.0 -> 1.0.2 (*)
| +--- io.dropwizard:dropwizard-lifecycle:1.0.0 -> 1.0.2 (*)
| +--- io.dropwizard:dropwizard-servlets:1.0.0 -> 1.0.2 (*)
| +--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| +--- io.dropwizard.metrics:metrics-healthchecks:3.1.2 (*)
| +--- com.google.inject:guice:4.0 -> 4.1.0 (*)
| +--- com.google.inject.extensions:guice-servlet:4.0 (*)
| +--- org.glassfish.jersey.core:jersey-server:2.23.1 (*)
| +--- org.reflections:reflections:0.9.10
| | +--- com.google.guava:guava:18.0 -> 19.0
| | +--- org.javassist:javassist:3.18.2-GA
| | \--- com.google.code.findbugs:annotations:2.0.1 -> 3.0.1 (*)
| +--- javax.servlet:javax.servlet-api:3.1.0
| +--- javax.inject:javax.inject:1
| +--- org.slf4j:slf4j-api:1.7.12 -> 1.7.21
| +--- org.glassfish.hk2:hk2-api:2.4.0-b34 (*)
| +--- javax.ws.rs:javax.ws.rs-api:2.0.1
| \--- com.google.guava:guava:18.0 -> 19.0
+--- com.yunspace.dropwizard:dropwizard-xml:41
+--- io.dropwizard:dropwizard-assets:1.0+ -> 1.0.2
| +--- io.dropwizard:dropwizard-core:1.0.2 (*)
| \--- io.dropwizard:dropwizard-servlets:1.0.2 (*)
+--- io.dropwizard:dropwizard-core:1.0+ -> 1.0.2 (*)
+--- io.dropwizard:dropwizard-views:1.0+ -> 1.0.2
| \--- io.dropwizard:dropwizard-core:1.0.2 (*)
+--- io.dropwizard:dropwizard-metrics:1.0+ -> 1.0.2 (*)
+--- io.dropwizard:dropwizard-metrics-graphite:1.0+ -> 1.0.2
| +--- io.dropwizard:dropwizard-metrics:1.0.2 (*)
| \--- io.dropwizard.metrics:metrics-graphite:3.1.2
| \--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
+--- io.dropwizard:dropwizard-servlets:1.0+ -> 1.0.2 (*)
+--- io.dropwizard:dropwizard-views-mustache:1.0+ -> 1.0.2
| +--- io.dropwizard:dropwizard-views:1.0.2 (*)
| \--- com.github.spullara.mustache.java:compiler:0.9.2
+--- com.google.inject.extensions:guice-throwingproviders:3+ -> 3.0
| \--- com.google.inject:guice:3.0 -> 4.1.0 (*)
+--- com.newrelic.agent.java:newrelic-api:3.30.1
+--- com.newrelic.agent.java:newrelic-agent:3.30.1
+--- project :referenceCache
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.0.0 (*)
| +--- com.google.code.gson:gson:2.5
| +--- com.google.guava:guava:19.0-rc3 -> 19.0
| +--- com.google.inject:guice:4+ -> 4.1.0 (*)
| +--- org.glassfish.jersey.core:jersey-client:2.22.1 -> 2.23.1 (*)
| +--- javax.inject:javax.inject:1
| +--- org.slf4j:slf4j-api:1.7.13 -> 1.7.21
| +--- io.dropwizard.metrics:metrics-core:3.1.2 (*)
| +--- project :domain
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.0.0 (*)
| | +--- org.projectlombok:lombok:1.16.8
| | +--- org.slf4j:slf4j-api:1.7.13 -> 1.7.21
| | +--- com.fasterxml.jackson.core:jackson-databind:2.5.2 -> 2.7.6 (*)
| | +--- com.conducivetech:processedFlightHistory:20151006102512
| | | +--- com.intellij:annotations:12.0
| | | +--- joda-time:joda-time:2.7+ -> 2.9.4
| | | +--- org.slf4j:slf4j-api:1.7.2 -> 1.7.21
| | | +--- com.yammer.metrics:metrics-core:2.2.0
| | | | \--- org.slf4j:slf4j-api:1.7.2 -> 1.7.21
| | | +--- com.yammer.metrics:metrics-graphite:2.2.0
| | | | +--- com.yammer.metrics:metrics-core:2.2.0 (*)
| | | | \--- org.slf4j:slf4j-api:1.7.2 -> 1.7.21
| | | +--- postgresql:postgresql:9.2-1003.jdbc4
| | | +--- com.google.code.gson:gson:2.2.2 -> 2.5
| | | +--- org.projectlombok:lombok:1.14.4 -> 1.16.8
| | | +--- commons-lang:commons-lang:2.6
| | | \--- joda-time:joda-time:2.2 -> 2.9.4
| | +--- org.reflections:reflections:0.9.10 (*)
| | \--- com.google.guava:guava:19.0-rc3 -> 19.0
| \--- project :hub
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.0.0 (*)
| +--- org.projectlombok:lombok:1.16.8
| +--- com.google.code.gson:gson:2.5
| +--- com.google.guava:guava:19.0-rc3 -> 19.0
| +--- org.glassfish.jersey.core:jersey-client:2.22.1 -> 2.23.1 (*)
| \--- org.slf4j:slf4j-api:1.7.13 -> 1.7.21
+--- com.flightstats:java-threescale:20160706085811
| +--- org.projectlombok:lombok:1.16.6 -> 1.16.8
| +--- org.slf4j:slf4j-api:1.7.12 -> 1.7.21
| +--- com.google.guava:guava:18.0 -> 19.0
| +--- org.glassfish.jersey.core:jersey-common:2.17 -> 2.23.1 (*)
| +--- org.simpleframework:simple-xml:2.7.1
| | +--- stax:stax-api:1.0.1
| | +--- stax:stax:1.2.0
| | | \--- stax:stax-api:1.0.1
| | \--- xpp3:xpp3:1.1.3.3
| \--- com.google.code.gson:gson:2.3.1 -> 2.5
+--- org.slf4j:slf4j-api:1.7.13 -> 1.7.21
+--- com.fasterxml.jackson.core:jackson-databind:2.5.2 -> 2.7.6 (*)
+--- org.reflections:reflections:0.9.10 (*)
+--- com.google.guava:guava:19.0-rc3 -> 19.0
+--- junit:junit:4.12
| \--- org.hamcrest:hamcrest-core:1.3
+--- org.assertj:assertj-core:3.5+ -> 3.5.2
\--- org.mockito:mockito-core:2.1+ -> 2.1.0
+--- net.bytebuddy:byte-buddy:1.4.26
+--- net.bytebuddy:byte-buddy-agent:1.4.26
\--- org.objenesis:objenesis:2.4
from dropwizard-guice.
I haven't had a chance to dig into the code yet, but my guess is that since UriBuilder
is a JAX-RS class it uses the service locator stuff to find the actual implementation to delegate to at runtime. The fix for #88 (released on 1.0.0.2) tries to ensure that the jersey2-guice gets loaded first which means that the service locator generator will be set to the GuiceServiceLocatorGeneratorStub
. But since your test never actually starts up a dropwizard app (the stub gets populated during startup) the stub is holding an empty reference which throws an exception when HK2 tries to access it
from dropwizard-guice.
If it works with 1.0.0.1 that would confirm my suspicion
from dropwizard-guice.
Yep, you nailed it. If I specify 1.0.0.1 the test passes, with 1.0.0.2 it fails.
If there's anything you'd like me to try, let me know, I'm happy to help.
from dropwizard-guice.
So this is interesting/odd....that particular test passes, but a different test in another module fails with the same error even with 1.0.0.1. So putting 1.0.0.1 didn't fix the problem, it just shuffled the classpath such that some UriBuilder invocations work and some don't.
from dropwizard-guice.
I'm guessing the underlying problem is related to this:
https://java.net/jira/si/jira.issueviews:issue-html/JERSEY-1950/JERSEY-1950.html
Apparently, there's a cyclic dependency introduced with Jersey2 and Guice, and Dropwizard 1.0 pulls in Jersey2.
from dropwizard-guice.
+1 to find a solution to this issue.
from dropwizard-guice.
I believe this happens when com.squarespace.jersey2-guice:0-jersey2-guice-spi
appears before org.glassfish.hk2:hk2-locator
in the classpath.
In this case the method JerseyGuiceUtils.isProviderPresent
returns true
and consequently getOrCreateGuiceServiceLocatorGenerator
goes into the first if
.
If HK2 appears first, it falls through to the hack of reflection on ServiceLocatorFactory
and things work differently.
Does it help?
from dropwizard-guice.
For me reverting to 1.0.0.1 version works.
My code that was breaking is not the test but the Clint code.
Client client = ClientBuilder.newClient(new ClientConfig().register(HelloClient.class));
WebTarget webTarget = client.target("http://localhost:9090/hello-world").queryParam("name", "Vijay");_
After reverting back a version , the above code worked for me
from dropwizard-guice.
what about newer versions of dropwizard-guice?
from dropwizard-guice.
+1 for fixing this issue
from dropwizard-guice.
+1 for a fix
from dropwizard-guice.
+1 seeing
WARN [2017-01-04 23:02:18,026] com.squarespace.jersey2.guice.JerseyGuiceUtils: It appears jersey2-guice-spi is either not present or in conflict with some other Jar: ServiceLocatorGeneratorImpl(hk2-locator, 608519258)
With DW 1.0.5, and DW guice 1.0.0.2
from dropwizard-guice.
I believe Squarespace/jersey2-guice#39 will fix the issue with using Jersey client in tests (specifically this line). I haven't had time to work on compatibility beyond dropwizard 1.0.0 but I'll try to get to it soon
from dropwizard-guice.
@peterbecker
If it helps anyone, this worked for me:
Basically the 1.0.0.3 was downloading org.glassfish.jersey.core:jersey-server:jar:2.23.2:compile
Forcing it to download the 2.23.1 seems to fix the issue.
<dependency>
<groupId>com.hubspot.dropwizard</groupId>
<artifactId>dropwizard-guice</artifactId>
<version>1.0.0.3</version>
<exclusions>
<exclusion>
<artifactId>org.glassfish.jersey.core</artifactId>
<groupId>jersey-server</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.23.1</version>
</dependency>
from dropwizard-guice.
I just released version 1.0.6.0 of dropwizard-guice which uses dropwizard 1.0.6. It should show up in Maven central soon and if you use that version you should be able to use dropwizard 1.0.6 without exclusions or mucking with versions. Still no reply from the jersey2-guice maintainers on the other issue though.
from dropwizard-guice.
Thanks
JerseyGuiceUtils.reset();
did the trick (with dropwizard 1.1.0, jersey 2.25.1 and dropwizard-guice 1.0.6.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
- DropWizard 0.9.1 support? HOT 10
- 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
- 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.