java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.platformThreadFactory()Ljava/util/concurrent/ThreadFactory;
java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.platformThreadFactory()Ljava/util/concurrent/ThreadFactory;
实际上我正在尝试在云中获取主题 pub/sub。当我发送请求 URL 以获取主题时,我已经使用 restful Web 服务编写了代码,但我遇到了上述错误。经过一番查找,它看起来像 pub/sub 0.17 版本和番石榴 19.o 版本的版本冲突,但我排除了番石榴 19 版本并添加了 18 版本,但同样的异常一次又一次地出现。但是我尝试了所有番石榴版本但没有使用相同的错误。请指导我如何解决以及它为什么会出现。
我要在这里附上我的代码..
谢谢..
我的代码:
@Path("/topic")
public class PubSubServices
{
@Path("/gettopic")
@GET
@Produces({ MediaType.TEXT_HTML})
public Response getTopic() throws Exception {
String projectid="My-ProjectID";
String topicname="my-new-topic";
System.out.println("Project name is:"+projectid+" new topic name is:"+topicname);
try
{
TopicAdminClient topicAdminClient topicAdminClient=TopicAdminClient.create();
TopicName topicName = TopicName.create(projectid, topicname);
Topic topic = topicAdminClient.getTopic(topicName);
} catch(Exception e)
{
e.printStackTrace();
}
return Response.status(200).entity(topic.getName();).build();
}
Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>PubSub</groupId>
<artifactId>PubSub</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.17.2-alpha</version>
<exclusions>
<exclusion>
<artifactId>com.google</artifactId>
<groupId>guava</groupId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.22.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
<build>
<finalName>CloudSubPub1</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
我创建了 war 文件并上传到 glass fish 服务器。当我发送请求错误时..像 Guava-18 这样的接缝在运行时被旧版本覆盖,而 Guava-18 只在编译任务期间工作。
使用 Main 方法可以正常工作 gud(使用 main 方法测试)
代码:
package com.agro.pubsub.services;
import com.google.cloud.pubsub.spi.v1.TopicAdminClient;
import com.google.pubsub.v1.Topic;
import com.google.pubsub.v1.TopicName;
public class Test {
public static void main(String args[]) throws Exception
{
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
TopicName topicName = TopicName.create("My-project-Id", "my-new-topic123");
Topic topic = topicAdminClient.getTopic(topicName);
System.out.println(""+topic.getName());
}
}
}
Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>PubSub</groupId>
<artifactId>PubSub</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.17.2-alpha</version>
</dependencies>
</project>
Problem is that when I write code with restful web services with jersey I am getting above error, I am not able find solution.
Any solution for this please?
我找到了解决办法。我将番石榴 19 版本复制到玻璃鱼模块文件夹中
所以这意味着我正在用我的番石榴版本覆盖番石榴
已解决:我将 Guava 依赖项更新到最新版本并解决了问题
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>latest</version>
</dependency>
实际上我正在尝试在云中获取主题 pub/sub。当我发送请求 URL 以获取主题时,我已经使用 restful Web 服务编写了代码,但我遇到了上述错误。经过一番查找,它看起来像 pub/sub 0.17 版本和番石榴 19.o 版本的版本冲突,但我排除了番石榴 19 版本并添加了 18 版本,但同样的异常一次又一次地出现。但是我尝试了所有番石榴版本但没有使用相同的错误。请指导我如何解决以及它为什么会出现。 我要在这里附上我的代码.. 谢谢..
我的代码:
@Path("/topic")
public class PubSubServices
{
@Path("/gettopic")
@GET
@Produces({ MediaType.TEXT_HTML})
public Response getTopic() throws Exception {
String projectid="My-ProjectID";
String topicname="my-new-topic";
System.out.println("Project name is:"+projectid+" new topic name is:"+topicname);
try
{
TopicAdminClient topicAdminClient topicAdminClient=TopicAdminClient.create();
TopicName topicName = TopicName.create(projectid, topicname);
Topic topic = topicAdminClient.getTopic(topicName);
} catch(Exception e)
{
e.printStackTrace();
}
return Response.status(200).entity(topic.getName();).build();
}
Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>PubSub</groupId>
<artifactId>PubSub</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.17.2-alpha</version>
<exclusions>
<exclusion>
<artifactId>com.google</artifactId>
<groupId>guava</groupId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.22.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
<build>
<finalName>CloudSubPub1</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
我创建了 war 文件并上传到 glass fish 服务器。当我发送请求错误时..像 Guava-18 这样的接缝在运行时被旧版本覆盖,而 Guava-18 只在编译任务期间工作。
使用 Main 方法可以正常工作 gud(使用 main 方法测试)
代码:
package com.agro.pubsub.services;
import com.google.cloud.pubsub.spi.v1.TopicAdminClient;
import com.google.pubsub.v1.Topic;
import com.google.pubsub.v1.TopicName;
public class Test {
public static void main(String args[]) throws Exception
{
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
TopicName topicName = TopicName.create("My-project-Id", "my-new-topic123");
Topic topic = topicAdminClient.getTopic(topicName);
System.out.println(""+topic.getName());
}
}
}
Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>PubSub</groupId>
<artifactId>PubSub</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.17.2-alpha</version>
</dependencies>
</project>
Problem is that when I write code with restful web services with jersey I am getting above error, I am not able find solution. Any solution for this please?
我找到了解决办法。我将番石榴 19 版本复制到玻璃鱼模块文件夹中 所以这意味着我正在用我的番石榴版本覆盖番石榴
已解决:我将 Guava 依赖项更新到最新版本并解决了问题
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>latest</version>
</dependency>