服务器 Tomcat v8.5 无法启动 hello world Jersey Web 服务
Server Tomcat v8.5 failed to start for hello world Jersey Web Service
我正在设置我的 Jersey Web 服务,但无法将其连接到 运行,Apache Tomcat 8.5 出错了。请参阅下面的详细信息,了解简单代码、我的库和错误。
我创建了一个动态 Web 项目...
我添加了 Jersey 文件...(我遗漏了什么吗?)
- javax.ws.rs-api.2.0.1.jar
- 球衣-client.jar
- 球衣-common.jar
- 球衣容器-servlet.jar
- 球衣容器-servlet.jar
- 泽西媒体-jaxb.jar
- 球衣-server.jar
我的Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<servlet>
<servlet-name>myApi</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<!-- The package where your resource classes are -->
<param-value>WS</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>testApi</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
我的Javaclass
package ws;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
@Path("test")
public class Connect {
@GET
@Path("test")
@Produces(MediaType.TEXT_PLAIN)
public String hello(){
return "hello world";
}
}
我之前的错误提示说无法启动Apachev8.5
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ThisApi]]
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ThisApi]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
... 6 more
Caused by: java.lang.NoClassDefFoundError: jersey/repackaged/com/google/common/base/Function
at org.glassfish.jersey.internal.ServiceFinder.<clinit>(ServiceFinder.java:165)
at org.glassfish.jersey.servlet.internal.ServletContainerProviderFactory.getAllServletContainerProviders(ServletContainerProviderFactory.java:66)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:134)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5178)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Caused by: java.lang.ClassNotFoundException: jersey.repackaged.com.google.common.base.Function
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
... 11 more
您缺少 jersey-guava.jar
,它应该包含 package-rebundled 版本的 Google Guava 类,包括 Function
。 Jersey 重新打包他们需要的确切版本,以便您仍然可以使用您喜欢的原始包结构中的 Guava 版本。参见 。
https://mvnrepository.com/artifact/org.glassfish.jersey.bundles.repackaged/jersey-guava
我正在设置我的 Jersey Web 服务,但无法将其连接到 运行,Apache Tomcat 8.5 出错了。请参阅下面的详细信息,了解简单代码、我的库和错误。
我创建了一个动态 Web 项目... 我添加了 Jersey 文件...(我遗漏了什么吗?)
- javax.ws.rs-api.2.0.1.jar
- 球衣-client.jar
- 球衣-common.jar
- 球衣容器-servlet.jar
- 球衣容器-servlet.jar
- 泽西媒体-jaxb.jar
- 球衣-server.jar
我的Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<servlet>
<servlet-name>myApi</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<!-- The package where your resource classes are -->
<param-value>WS</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>testApi</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
我的Javaclass
package ws;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
@Path("test")
public class Connect {
@GET
@Path("test")
@Produces(MediaType.TEXT_PLAIN)
public String hello(){
return "hello world";
}
}
我之前的错误提示说无法启动Apachev8.5
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ThisApi]]
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ThisApi]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
... 6 more
Caused by: java.lang.NoClassDefFoundError: jersey/repackaged/com/google/common/base/Function
at org.glassfish.jersey.internal.ServiceFinder.<clinit>(ServiceFinder.java:165)
at org.glassfish.jersey.servlet.internal.ServletContainerProviderFactory.getAllServletContainerProviders(ServletContainerProviderFactory.java:66)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:134)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5178)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Caused by: java.lang.ClassNotFoundException: jersey.repackaged.com.google.common.base.Function
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
... 11 more
您缺少 jersey-guava.jar
,它应该包含 package-rebundled 版本的 Google Guava 类,包括 Function
。 Jersey 重新打包他们需要的确切版本,以便您仍然可以使用您喜欢的原始包结构中的 Guava 版本。参见 。
https://mvnrepository.com/artifact/org.glassfish.jersey.bundles.repackaged/jersey-guava