Skip to content

[pulsar-client] fix protobuf dependency with shaded pulsar-client#4523

Closed
rdhabalia wants to merge 1 commit intoapache:masterfrom
rdhabalia:pl_shad_proto
Closed

[pulsar-client] fix protobuf dependency with shaded pulsar-client#4523
rdhabalia wants to merge 1 commit intoapache:masterfrom
rdhabalia:pl_shad_proto

Conversation

@rdhabalia
Copy link
Contributor

Motivation

Right now, pulsar-client doesn't include classes of pulsar::protobuf-shaded and because of that it throws below runtime error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/pulsar/shaded/com/google/protobuf/v241/UninitializedMessageException
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
	at java.lang.Class.getConstructor0(Class.java:3075)
	at java.lang.Class.getConstructor(Class.java:1825)
	at org.apache.pulsar.client.internal.ReflectionUtils.getConstructor(ReflectionUtils.java:52)
	at org.apache.pulsar.client.internal.DefaultImplementation.<clinit>(DefaultImplementation.java:55)
	at org.apache.pulsar.client.api.Schema.<clinit>(Schema.java:117)
Caused by: java.lang.ClassNotFoundException: org.apache.pulsar.shaded.com.google.protobuf.v241.UninitializedMessageException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 11 more

@rdhabalia rdhabalia added this to the 2.4.0 milestone Jun 12, 2019
@rdhabalia rdhabalia self-assigned this Jun 12, 2019
@sijie
Copy link
Member

sijie commented Jun 13, 2019

@rdhabalia not sure if I understand the problem here. If protobuf-shaded is not added, the shaded client should be always not usable, no?

@rdhabalia
Copy link
Contributor Author

If protobuf-shaded is not added, the shaded client should be always not usable, no?

it doesn't work when we try to exclude all transitive dependencies from it. pulsar-client is a shaded jar so, we don't want to fetch any transitive dependencies from it. So, it throws above RunTimeException when we exclude all the dependencies from it because it excludes protobuf and client-api as well..

  <dependency>
	<groupId>${cms.groupId}</groupId>
	<artifactId>pulsar-client</artifactId>
	<exclusions>
		<exclusion>
			<!-- Exclude all dependencies since we're fetching the shaded jar -->
			<groupId>*</groupId>
			<artifactId>*</artifactId>
		</exclusion>
	</exclusions>
</dependency>                  

@sijie
Copy link
Member

sijie commented Jun 13, 2019

@rdhabalia okay. but how about other transitive dependencies? Is protobuf-shaded the only transitive dependency?

This doesn't sounds like a correct approach to me.

@merlimat
Copy link
Contributor

pulsar-client is a shaded jar so, we don't want to fetch any transitive dependencies from it

There are still some of the dependencies that are not being shaded (eg: lz4-java because the JNI would not work if shaded)

@sijie
Copy link
Member

sijie commented Jun 14, 2019

@rdhabalia my feeling this issue is not a blocker for 2.4.0. Can we move it to 2.5.0? If we come to an agreement before 2.4.0 release, we can still include it in 2.4.0.

@rdhabalia rdhabalia modified the milestones: 2.4.0, 2.5.0 Jun 14, 2019
@rdhabalia
Copy link
Contributor Author

yes moving to 2.5 for now and I will see if it's possible to create a shaded jar without fetching any transitive dependecies.

@aahmed-se
Copy link
Contributor

@rdhabalia is this ready for review ?

@rdhabalia rdhabalia closed this Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants