slachiewicz / caliper

Automatically exported from code.google.com/p/caliper
Apache License 2.0
0 stars 0 forks source link

Use the Maven Shade Plugin to hide Jersey, et. al. #257

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set up a project that depends on Apache Jersey.
2. Try running caliper benchmark w/ Jersey on the classpath.
3. Fail.

What is the expected output? What do you see instead?

Expected: test should run.

Actual: Exception (see below) if Jersey is on the classpath, regardless of 
whether I list it before or after the caliper uber-jar.

What version of the product are you using? On what operating system?
1.0-beta1

Please provide any additional information below.

Details from caliper log:

Jun 03, 2013 6:50:07 PM com.sun.jersey.spi.inject.Errors processErrorMessages
SEVERE: The following errors and warnings have been detected with resource 
and/or provider classes:
  SEVERE: Missing dependency for field: javax.ws.rs.core.UriInfo com.sun.jersey.server.impl.template.ViewableMessageBodyWriter.ui
  SEVERE: Missing dependency for field: com.sun.jersey.spi.template.TemplateContext com.sun.jersey.server.impl.template.ViewableMessageBodyWriter.tc

com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, java.lang.NoSuchMethodError: 
com.sun.jersey.core.spi.component.ProviderServices.<init>(Ljava/lang/Class;Lcom/
sun/jersey/core/spi/component/ProviderFactory;Ljava/util/Set;Ljava/util/Set;)V
  at com.google.caliper.runner.HttpUploader.<init>(HttpUploader.java:37)
  while locating com.google.caliper.runner.HttpUploader
  at com.google.caliper.runner.ExperimentingRunnerModule.provideResultProcessors(ExperimentingRunnerModule.java:55)
  while locating com.google.common.collect.ImmutableSet<com.google.caliper.api.ResultProcessor>
    for parameter 5 at com.google.caliper.runner.ExperimentingCaliperRun.<init>(ExperimentingCaliperRun.java:138)
  while locating com.google.caliper.runner.ExperimentingCaliperRun
  while locating com.google.caliper.runner.CaliperRun

1 error
    at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)

An unexpected exception has been thrown by the caliper runner.
Please see https://sites.google.com/site/caliperusers/issues
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013)
    at com.google.caliper.runner.CaliperMain.exitlessMain(CaliperMain.java:130)
    at com.google.caliper.runner.CaliperMain.main(CaliperMain.java:78)
    at com.google.caliper.runner.CaliperMain.main(CaliperMain.java:66)
    at com.scarabresearch.benchmark.CounterBenchmark.main(CounterBenchmark.java:25)
Caused by: java.lang.NoSuchMethodError: 
com.sun.jersey.core.spi.component.ProviderServices.<init>(Ljava/lang/Class;Lcom/
sun/jersey/core/spi/component/ProviderFactory;Ljava/util/Set;Ljava/util/Set;)V
    at com.sun.jersey.api.client.Client.init(Client.java:242)
    at com.sun.jersey.api.client.Client.access$000(Client.java:118)
    at com.sun.jersey.api.client.Client$1.f(Client.java:191)
    at com.sun.jersey.api.client.Client$1.f(Client.java:187)
    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
    at com.sun.jersey.api.client.Client.<init>(Client.java:187)
    at com.sun.jersey.api.client.Client.<init>(Client.java:159)
    at com.sun.jersey.api.client.Client.create(Client.java:669)
    at com.google.caliper.runner.HttpUploader.<init>(HttpUploader.java:37)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.google.inject.internal.DefaultConstructionProxyFactory$2.newInstance(DefaultConstructionProxyFactory.java:85)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
    at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
    at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013)
    at com.google.caliper.runner.ExperimentingRunnerModule.provideResultProcessors(ExperimentingRunnerModule.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.google.inject.internal.ProviderMethod.get(ProviderMethod.java:104)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
    at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
    at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
    ... 5 more

Original issue reported on code.google.com by phraktle on 3 Jun 2013 at 5:31

GoogleCodeExporter commented 9 years ago
Note: the main problem is not that there are conflicting versions of Jersey on 
the classpath (the benchmark doesn't need it). The problem is that no matter if 
caliper-1.0-beta-1-all.jar is first or last on the classpath when launching the 
benchmark, I still get this error.

Original comment by phraktle on 3 Jun 2013 at 5:48

GoogleCodeExporter commented 9 years ago
What version of Jersey are you using?

Original comment by gak@google.com on 3 Jun 2013 at 6:38

GoogleCodeExporter commented 9 years ago
In this particular project Jersey 1.1.5 is used.

Original comment by phraktle on 4 Jun 2013 at 7:14

GoogleCodeExporter commented 9 years ago
OK, so it seems like the version skew is the issue.  Caliper uses Jersey 1.11 
to upload results.  Ideally, we'd use the Maven Shade plugin to repackage 
Jersey, but my first attempt failed because some reflection was causing it to 
fail. (You can see the commented out section in the pom.)  Some quick Googling 
suggests that 
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformer
s.html#ServicesResourceTransformer may be the solution.

Original comment by gak@google.com on 4 Jun 2013 at 5:43

GoogleCodeExporter commented 9 years ago
I also ran into incompatibilities with a conflicting version of Guava.  This is 
a deal-braker for me :-(

Original comment by David.W....@gmail.com on 19 Aug 2013 at 4:26