question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dependency issue with google-cloud-pubsub and Apache Beam packages

See original GitHub issue

I get a Maven install conflict between the Google Cloud pub/sub artifact:

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-pubsub</artifactId>
  <version>1.53.0</version>
</dependency>

and the Apache Beam google-cloud-dataflow-java-sdk-all artifact:

    <dependency>
      <groupId>com.google.cloud.dataflow</groupId>
      <artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
      <version>2.5.0</version>
    </dependency>

google-cloud-pubsub has various sub-dependencies that rely on io.grpc:grpc-core:jar:1.16.1, and subdependencies of google-cloud-dataflow-java-sdk-all depend on various versions of io.grpc:grpc-core:jar that do not match this.

The full Maven conflict error message I get is

Could not resolve version conflict among [com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> com.google.cloud:google-cloud-core-grpc:jar:1.53.0 -> io.grpc:grpc-protobuf:jar:1.16.1 -> io.grpc:grpc-core:jar:1.16.1, com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> com.google.cloud:google-cloud-core-grpc:jar:1.53.0 -> io.grpc:grpc-protobuf:jar:1.16.1 -> io.grpc:grpc-protobuf-lite:jar:1.16.1 -> io.grpc:grpc-core:jar:1.16.1, com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> io.grpc:grpc-netty-shaded:jar:1.16.1 -> io.grpc:grpc-core:jar:[1.16.1,1.16.1], com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> io.grpc:grpc-stub:jar:1.16.1 -> io.grpc:grpc-core:jar:1.16.1, com.google.cloud:google-cloud-pubsub:jar:1.53.0 -> io.grpc:grpc-auth:jar:1.16.1 -> io.grpc:grpc-core:jar:[1.16.1,1.16.1], com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-core:jar:1.2.0, com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-netty:jar:1.2.0 -> io.grpc:grpc-core:jar:[1.2.0,1.2.0], com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> com.google.cloud.bigtable:bigtable-protos:jar:1.0.0-pre3 -> io.grpc:grpc-core:jar:1.5.0, com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> com.google.cloud.bigtable:bigtable-client-core:jar:1.0.0 -> io.grpc:grpc-core:jar:1.7.0, com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> com.google.cloud.bigtable:bigtable-client-core:jar:1.0.0 -> io.opencensus:opencensus-contrib-grpc-util:jar:0.7.0 -> io.grpc:grpc-core:jar:1.6.1, com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-all:jar:1.2.0 -> io.grpc:grpc-core:jar:[1.2.0,1.2.0], com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-all:jar:1.2.0 -> io.grpc:grpc-okhttp:jar:1.2.0 -> io.grpc:grpc-core:jar:[1.2.0,1.2.0], com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0 -> org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0 -> io.grpc:grpc-all:jar:1.2.0 -> io.grpc:grpc-protobuf-nano:jar:1.2.0 -> io.grpc:grpc-core:jar:1.2.0

I’ve documented my specific issue and attempts to fix it more fully here:

https://stackoverflow.com/questions/53424272/maven-conflict-in-java-app-with-google-cloud-core-grpc-dependency

Can someone please recommend a workaround? I need one urgently.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sduskiscommented, Nov 26, 2018

We need to document how to use google-cloud-java libraries in Beam.

I suggest that you upgrade to beam 2.8.0 and use google-cloud-pubsub 1.49.0.

The core of the problem is that Beam and the google-cloud-library clients use different grpc versions. First, I would suggest upgrading to beam 2.8.0 which uses grpc 1.13.1. I did some digging, and found that google-cloud-pubsub 1.49.0 used grpc 1.13.1 as well.

0reactions
KishoreNamalacommented, Mar 20, 2019

@chalcrow - I encountered this error and used the workaround mentioned in the above link. It resolved the compile error but broke my pubsub client while trying to publish to a topic.

Here is the error from my pubsub client (trying to create a publisher with custom batch settings).

Exception in thread "main" java.lang.NoSuchFieldError: transportTracerFactory
	at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.buildTransportFactory(NettyChannelBuilder.java:394)
	at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:266)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:223)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:169)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:156)
	at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:157)
	at com.google.cloud.pubsub.v1.stub.GrpcPublisherStub.create(GrpcPublisherStub.java:161)
	at com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:149)
	at com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:78)
	at com.google.cloud.pubsub.v1.Publisher$Builder.build(Publisher.java:614)
	at com.techm.data.service.PublisherSvc.getPublisherWithCustomBatchSettings(PublisherSvc.java:155)
	at com.techm.data.service.PublisherSvc.publishMessageBatchToATopic(PublisherSvc.java:116)
	at com.techm.data.client.CreateTopicAndPublishMessages.publishObjectMessages(CreateTopicAndPublishMessages.java:99)
	at com.techm.data.client.CreateTopicAndPublishMessages.main(CreateTopicAndPublishMessages.java:158)

And here is the method creating the publisher

	public Publisher getPublisherWithCustomBatchSettings(ProjectTopicName topicName) throws Exception {
		// [START pubsub_publisher_batch_settings]
		// Batch settings control how the publisher batches messages
		long requestBytesThreshold = 5000L; // default : 1 byte
		long messageCountBatchSize = 10L; // default : 1 message

		Duration publishDelayThreshold = Duration.ofMillis(100); // default : 1 ms

		// Publish request get triggered based on request size, messages count & time
		// since last publish
		BatchingSettings batchingSettings = BatchingSettings.newBuilder()
				.setElementCountThreshold(messageCountBatchSize).setRequestByteThreshold(requestBytesThreshold)
				.setDelayThreshold(publishDelayThreshold).build();

		Publisher publisher = Publisher.newBuilder(topicName).setBatchingSettings(batchingSettings).build();
		// [END pubsub_publisher_batch_settings]
		return publisher;
	}
Read more comments on GitHub >

github_iconTop Results From Across the Web

[#BEAM-6118] Maven dependency conflicts between google ...
Maven dependency conflicts between google-cloud-pubsub and Apache Beam packages. Status: Assignee: Priority: Resolution: Open. Unassigned.
Read more >
SDK and Worker Dependencies - Dataflow - Google Cloud
This page contains dependency and worker package information for Apache Beam and Dataflow SDK releases: Apache Beam 2.x SDKs for Java; Apache Beam...
Read more >
Google Cloud Dataflow (Python) - Not installing dependencies ...
As explained in the Apache Beam documentation about how to handle Python dependencies in a pipeline, the recommended approach for PyPI ...
Read more >
Installing Python Dependencies in Dataflow - Medium
When you run a Dataflow pipeline, your pipeline may need python packages other than apache-beam. The dependency may be public packages from PyPI...
Read more >
beam-sdks-java-io-google-cloud-platform : 2.28.0
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found