繁体   English   中英

java.lang.NoClassDefFoundError:com / google / common / base / MoreObjects在appengine上初始化pubsub时

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

我尝试在appEngine上运行此代码(在我的web.xml中定义了java8)

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;
}

我收到此错误:

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)

我怎样才能解决这个问题?

尝试使用guava 18.0或更高版本,这将解决问题。

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>18.0</version>
</dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM