我从泽西1.19搬到了泽西2.27。我得到了一个关于Guava的错误。我想知道Guava有什么关系。这是我的pom.xml文件:
<?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"
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>gr.iti.sodalite</groupId>
<artifactId>semantic-reasoner</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>reasoning-engine</module>
<module>reasoner-api</module>
</modules>
<properties>
<jersey2.version>2.27</jersey2.version>
<jaxrs.version>2.1.1</jaxrs.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-bundle -->
<!-->dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency-->
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-servlet -->
<!-- dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.19</version>
</dependency-->
<!-- https://mvnrepository.com/artifact/io.swagger/swagger-jersey2-jaxrs -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-runtime</artifactId>
<version>3.4.3</version>
<type>pom</type>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.eclipse.rdf4j</groupId> -->
<!-- <artifactId>rdf4j-sparqlbuilder</artifactId> -->
<!-- <version>3.0.0</version> -->
<!-- </dependency> -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.8</version>
</dependency>
<dependency>
<groupId>com.ontotext.graphdb</groupId>
<artifactId>graphdb-free-runtime</artifactId>
<version>9.4.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>reasoner-api</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<!-- configuration>
<source>8</source>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我的web.xml文件:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<!-- For Jersey 1.x -->
<!-- servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class-->
<!-- For Jersey 2.x -->
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>
io.swagger.jaxrs.json,
io.swagger.jaxrs.listing,
restapi
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/v0.6/*</url-pattern>
</servlet-mapping>
</web-app>
web应用程序正在Tomcat9上运行。在webapps文件夹中部署reasoner.war文件并启动应用程序时,会出现以下错误:
关注:java.lang.nosuchmethoderror:'com.google.common.util.concurrent.listengExecutorService
> Nov 20, 2020 2:47:59 PM org.apache.catalina.core.ApplicationContext
> log SEVERE: Servlet.init() for servlet [Jersey Web Application] threw
> exception MultiException stack 1 of 2 java.lang.NoSuchMethodError:
> 'com.google.common.util.concurrent.ListeningExecutorService
> com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()'
> at
> org.glassfish.jersey.server.ServerExecutorsFactory$2.getRespondingExecutor(ServerExecutorsFactory.java:89)
> at
> org.glassfish.jersey.process.internal.ExecutorsFactory.getInitialRespondingExecutor(ExecutorsFactory.java:126)
> at
> org.glassfish.jersey.server.ServerExecutorsFactory.<init>(ServerExecutorsFactory.java:85)
> at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method) at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> at
> java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at
> java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
> at
> java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
> at
> org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1092)
> at
> org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:261)
> at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:336)
> at
> org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
> at
> org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
> at
> org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2296)
> at
> org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:556)
> at
> org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77)
> at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:792)
> at
> org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:797)
> at
> org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:870)
> at
> org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:862)
> at
> org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:484)
> at
> org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:161)
> at
> org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:286)
> at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289) at
> org.glassfish.jersey.internal.Errors$2.call(Errors.java:286) at
> org.glassfish.jersey.internal.Errors.process(Errors.java:315) at
> org.glassfish.jersey.internal.Errors.process(Errors.java:297) at
> org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
> at
> org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:283)
> at
> org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:283)
> at
> org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
> at
> org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
> at javax.servlet.GenericServlet.init(GenericServlet.java:158) at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1134)
> at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
> at
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)
> at
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4872)
> at
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
> at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
> at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
> at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
> at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1848)
> at
> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
> at
> org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
> at
> java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
> at
> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
> at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
> at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576)
> at
> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
> at
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
> at
> org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
> at
> org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
> at
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936)
> at
> org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
> at
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
> at
> org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
> at
> java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
> at
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
> at
> org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at
> org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at
> org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method) at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:564) at
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343) at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
> MultiException stack 2 of 2 java.lang.IllegalStateException: Unable to
> perform operation: create on
> org.glassfish.jersey.server.ServerExecutorsFactory at
> org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:363) at
> org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
> at
> org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
> at
> org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2296)
> at
> org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:556)
> at
> org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77)
> at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:792)
> at
> org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:797)
> at
> org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:870)
> at
> org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:862)
> at
> org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:484)
> at
> org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:161)
> at
> org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:286)
> at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289) at
> org.glassfish.jersey.internal.Errors$2.call(Errors.java:286) at
> org.glassfish.jersey.internal.Errors.process(Errors.java:315) at
> org.glassfish.jersey.internal.Errors.process(Errors.java:297) at
> org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
> at
> org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:283)
> at
> org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:283)
> at
> org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
> at
> org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
> at javax.servlet.GenericServlet.init(GenericServlet.java:158) at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1134)
> at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
> at
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)
> at
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4872)
> at
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
> at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
> at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
> at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
> at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1848)
> at
> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
> at
> org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
> at
> java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
> at
> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
> at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
> at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576)
> at
> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
> at
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
> at
> org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
> at
> org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
> at
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936)
> at
> org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
> at
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
> at
> org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
> at
> java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
> at
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
> at
> org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at
> org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at
> org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method) at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:564) at
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343) at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
>
> Nov 20, 2020 2:47:59 PM org.apache.catalina.core.StandardContext
> loadOnStartup SEVERE: Servlet [Jersey Web Application] in web
> application [/reasoner-api] threw load() exception
> java.lang.NoSuchMethodError:
> 'com.google.common.util.concurrent.ListeningExecutorService
> com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()'
> at
> org.glassfish.jersey.server.ServerExecutorsFactory$2.getRespondingExecutor(ServerExecutorsFactory.java:89)
> at
> org.glassfish.jersey.process.internal.ExecutorsFactory.getInitialRespondingExecutor(ExecutorsFactory.java:126)
> at
> org.glassfish.jersey.server.ServerExecutorsFactory.<init>(ServerExecutorsFactory.java:85)
> at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
问题:你知道如何解决这些错误吗?
1条答案
按热度按时间ijxebb2r1#
为了从jersey 1.x迁移到jersey 2.x,我通过向pom.xml添加以下依赖项来解决这个问题。另外,因为我使用Java11,所以应该使用jersey>=2.27版本。
pom.xml文件