Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Fix jaeger-client dependency jaeger-thrift no-shadow artifact #486

Merged

Conversation

jpkrohling
Copy link
Collaborator

Signed-off-by: Juraci Paixão Kröhling juraci@kroehling.de

Which problem is this PR solving?

Basically, when using the jaeger-client, there's a runtime exception like:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.opentracing.Tracer]: Factory method 'getTracer' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/thrift/protocol/TProtocolFactory
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	... 39 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/apache/thrift/protocol/TProtocolFactory
	at io.jaegertracing.thrift.internal.senders.ThriftSenderFactory.getSender(ThriftSenderFactory.java:34) ~[jaeger-thrift-0.30.1-no-shadow.jar:0.30.1]
	at io.jaegertracing.internal.senders.SenderResolver.getSenderFromFactory(SenderResolver.java:96) ~[jaeger-core-0.30.1.jar:0.30.1]
	at io.jaegertracing.internal.senders.SenderResolver.resolve(SenderResolver.java:80) ~[jaeger-core-0.30.1.jar:0.30.1]
	at io.jaegertracing.Configuration$SenderConfiguration.getSender(Configuration.java:630) ~[jaeger-core-0.30.1.jar:0.30.1]
	at io.jaegertracing.Configuration$ReporterConfiguration.getReporter(Configuration.java:516) ~[jaeger-core-0.30.1.jar:0.30.1]
	at io.jaegertracing.Configuration$ReporterConfiguration.access$000(Configuration.java:476) ~[jaeger-core-0.30.1.jar:0.30.1]
	at io.jaegertracing.Configuration.getTracerBuilder(Configuration.java:210) ~[jaeger-core-0.30.1.jar:0.30.1]
	at io.jaegertracing.Configuration.getTracer(Configuration.java:226) ~[jaeger-core-0.30.1.jar:0.30.1]
	at io.jaegertracing.tracerresolver.internal.JaegerTracerResolver.resolve(JaegerTracerResolver.java:25) ~[jaeger-tracerresolver-0.30.1.jar:0.30.1]
	at io.jaegertracing.tracerresolver.internal.JaegerTracerResolver.resolve(JaegerTracerResolver.java:21) ~[jaeger-tracerresolver-0.30.1.jar:0.30.1]
	at io.opentracing.contrib.tracerresolver.TracerResolver.resolveTracer(TracerResolver.java:75) ~[opentracing-tracerresolver-0.1.4.jar:na]
	at io.opentracing.contrib.spring.web.autoconfig.TracerAutoConfiguration.getTracer(TracerAutoConfiguration.java:41) ~[opentracing-spring-web-autoconfigure-0.2.1.jar:na]
	at io.opentracing.contrib.spring.web.autoconfig.TracerAutoConfiguration$$EnhancerBySpringCGLIB$$f1d2c92.CGLIB$getTracer$0(<generated>) ~[opentracing-spring-web-autoconfigure-0.2.1.jar:na]
	at io.opentracing.contrib.spring.web.autoconfig.TracerAutoConfiguration$$EnhancerBySpringCGLIB$$f1d2c92$$FastClassBySpringCGLIB$$dbf4ecf.invoke(<generated>) ~[opentracing-spring-web-autoconfigure-0.2.1.jar:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	at io.opentracing.contrib.spring.web.autoconfig.TracerAutoConfiguration$$EnhancerBySpringCGLIB$$f1d2c92.getTracer(<generated>) ~[opentracing-spring-web-autoconfigure-0.2.1.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_172]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_172]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_172]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_172]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
	... 40 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.thrift.protocol.TProtocolFactory
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_172]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_172]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_172]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_172]
	... 62 common frames omitted

Short description of the changes

  • The no-shadow dependency is caused by a previous fix to the test classpath. As such, we just need to add the no-shadow dependency to the test classpath.

@ghost ghost assigned jpkrohling Jul 11, 2018
@ghost ghost added the review label Jul 11, 2018
@jpkrohling jpkrohling requested a review from objectiser July 11, 2018 15:11
@pavolloffay
Copy link
Member

Can we have a test for this?

@jpkrohling jpkrohling force-pushed the Fix-Dependency-on-Shadow branch from c615eda to a106b75 Compare July 11, 2018 16:02
@jpkrohling
Copy link
Collaborator Author

Can we have a test for this?

We do have a test in this module, but it won't catch the runtime issues, as the classpath for the test isn't the same as the classpath for a consumer of this dependency.

We could certainly have an integration test consuming this artifact, though. Should we change the crossdock module to use it?

@objectiser
Copy link
Contributor

@jpkrohling @pavolloffay As with other decisions that have been made during the latest refactoring, my preference would be to remove the 'no-shadow' jar until someone actually identifies a usecase that is required. So we just include the shadow jar as the only jaeger-thrift artifact.

@jpkrohling
Copy link
Collaborator Author

So we just include the shadow jar as the only jaeger-thrift artifact

The tricky part is to do that with the final pom, while still having the proper dependencies being pulled (shadow or thrift+okhttp) for the tests.

@pavolloffay
Copy link
Member

pavolloffay commented Jul 11, 2018

We do have a test in this module, but it won't catch the runtime issues, as the classpath for the test isn't the same as the classpath for a consumer of this dependency.

I don't see how the test classpath is different, there is only added junit.

The test should throw java.lang.NoClassDefFoundError: org/apache/thrift/protocol/TProtocolFactory when create UdpSender - tested on the master/head

@jpkrohling jpkrohling force-pushed the Fix-Dependency-on-Shadow branch from a106b75 to 18496ff Compare July 11, 2018 16:30
@codecov
Copy link

codecov bot commented Jul 11, 2018

Codecov Report

Merging #486 into master will increase coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #486      +/-   ##
============================================
+ Coverage     88.27%   88.32%   +0.05%     
+ Complexity      499      498       -1     
============================================
  Files            65       65              
  Lines          1859     1859              
  Branches        242      242              
============================================
+ Hits           1641     1642       +1     
+ Misses          141      139       -2     
- Partials         77       78       +1
Impacted Files Coverage Δ Complexity Δ
...ing/internal/samplers/RemoteControlledSampler.java 89.53% <0%> (-1.17%) 17% <0%> (-1%)
...egertracing/internal/reporters/RemoteReporter.java 85.71% <0%> (+2.38%) 7% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9e0282...6e17d5f. Read the comment docs.

@jpkrohling
Copy link
Collaborator Author

You are absolutely correct, @pavolloffay. I messed up the dependencies and I even remember having this exception, but thought it was something else.

@jpkrohling jpkrohling force-pushed the Fix-Dependency-on-Shadow branch 6 times, most recently from 9c96e9a to 520d103 Compare July 12, 2018 13:46
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@jpkrohling jpkrohling force-pushed the Fix-Dependency-on-Shadow branch from 520d103 to 6e17d5f Compare July 12, 2018 13:50
@jpkrohling jpkrohling merged commit 6e17d5f into jaegertracing:master Jul 12, 2018
@ghost ghost removed the review label Jul 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants