Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects when initializing pubsub on appengine

I try to run this code on appEngine (with java8 defined in my web.xml)

public TopicName createTopic(final String topicNameStr) throws Exception {
    checkInit();

    final TopicAdminSettings topicAdminSettings =
            TopicAdminSettings.defaultBuilder()
                    .setChannelProvider(channelProvider)
                    .build();

    TopicName topicName = TopicName.create(projectId, topicNameStr);

    try (final TopicAdminClient topicAdminClient = TopicAdminClient.create(topicAdminSettings)) {
        topicAdminClient.createTopic(topicName);
    }
    return topicName;
}

and i get this error:

Uncaught exception from servlet
java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects
    at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:284)
    at com.google.api.gax.grpc.InstantiatingChannelProvider.createChannel(InstantiatingChannelProvider.java:135)
    at com.google.api.gax.grpc.InstantiatingChannelProvider.getChannel(InstantiatingChannelProvider.java:116)
    at com.google.api.gax.grpc.ChannelAndExecutor.create(ChannelAndExecutor.java:65)
    at com.google.api.gax.grpc.ClientSettings.getChannelAndExecutor(ClientSettings.java:77)
    at com.google.cloud.pubsub.spi.v1.TopicAdminClient.<init>(TopicAdminClient.java:150)
    at com.google.cloud.pubsub.spi.v1.TopicAdminClient.create(TopicAdminClient.java:141)
    at linqmap.cloud.google.pubsub.PubSubFactory.createTopic(PubSubFactory.java:142)

how can i fix this?

like image 430
Elad Benda2 Avatar asked Jul 11 '17 17:07

Elad Benda2


1 Answers

Try using guava 18.0 or later this will resolve the issue.

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>18.0</version>
</dependency>
like image 134
soorapadman Avatar answered Nov 08 '22 09:11

soorapadman