gpt4 book ai didi

tomcat - Jersey :不存在 WebApplication 提供程序

转载 作者:行者123 更新时间:2023-11-28 21:55:31 28 4
gpt4 key购买 nike

我遵循此 http://www.ibm.com/developerworks/library/wa-aj-tomcat/ 中的确切步骤,并且我正确地包含了所有 jar (我相信)。而且我仍然遇到如下错误:

Jun 24, 2013 7:16:21 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Jun 24, 2013 7:16:21 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
com.sun.jersey.api.container.ContainerException: No WebApplication provider is present
at com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69)
at com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:360)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:275)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:585)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:213)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:342)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:516)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5407)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
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)

Jun 24, 2013 7:16:21 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /Jersey threw load() exception
com.sun.jersey.api.container.ContainerException: No WebApplication provider is present
at com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69)
at com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:360)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:275)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:585)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:213)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:342)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:516)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5407)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
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)

我只是做了第一步,打个招呼。我的 web.xml 和 java 文件如下:

package sample.hello.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;


@Path("/hello")
public class HelloResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayHello() {
return "Hello Jersey";
}
}

网络.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Jersey</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>sample.hello.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>

</web-app>

我已经谷歌了一段时间,找不到好的解决方案。顺便说一句,我的 jar 文件列表是:激活.jarasm-3.1.jarcom.sun.jersey.jersey-server-1.4.0.jarjaxb-api-2.2.5.jarjaxb-impl-2.2_1.jar Jersey -client.jar Jersey -core.jar Jersey -json-1.7.jar泽西 Spring -1.11-b02.jarjsr311-api.1.1.1.jarstax-api.jarwstx-asl.jar

这些 jar 是网上推荐的。我直接复制到WEB-INF/lib文件夹下。我担心的一件事是路径问题,之前有人告诉我我应该通过右键单击类项目->构建路径然后添加 jar 来添加一些 jar 。我也试过了,不是好消息。我正在运行 Tomcat7.0。网络也运行到错误报告页面。请帮忙!

我尝试了两个本地主机链接:8080/Jersey/WEB-INF/web.xml & 8080/Jersey/rest/hello。都失败了!

提前致谢。

最佳答案

我怀疑这可能与 StackOverflow 上的另一个问题重复。 Jersey No WebApplication provider is present when jersey-json dependency added

最后,确保 jersey-server 依赖于您的类路径。当您说“您的 jar 文件列表”时,您确定这些 jar 位于 Web 应用程序的类路径中吗?这可能是导致问题的 IDE 构建路径的功能。

如果您仍有问题,请提供您使用的 IDE,以及您的类路径是如何配置的。

关于tomcat - Jersey :不存在 WebApplication 提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17286865/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com