泽西岛:不存在WebApplication提供程序 [英] Jersey: No WebApplication provider is present

查看:86
本文介绍了泽西岛:不存在WebApplication提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此 http://www.ibm.com中遵循确切的步骤/developerworks/library/wa-aj-tomcat/,我正确地放入了所有罐子(我相信).而且我仍然收到类似以下的错误:

I follow exact steps in this http://www.ibm.com/developerworks/library/wa-aj-tomcat/, and I included all the jars correctly(i believe). And I still got the errors like the following:

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文件如下:

I just did the first step, show hello. My web.xml and java file are the following:

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

web.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文件列表是: activation.jar asm-3.1.jar com.sun.jersey.jersey-server-1.4.0.jar jaxb-api-2.2.5.jar jaxb-impl-2.2_1.jar jersey-client.jar jersey-core.jar jersey-json-1.7.jar jersey-spring-1.11-b02.jar jsr311-api.1.1.1.jar stax-api.jar wstx-asl.jar

I have been googling for a while, I couldn't find a good solution. btw, my jar file list is: activation.jar asm-3.1.jar com.sun.jersey.jersey-server-1.4.0.jar jaxb-api-2.2.5.jar jaxb-impl-2.2_1.jar jersey-client.jar jersey-core.jar jersey-json-1.7.jar jersey-spring-1.11-b02.jar jsr311-api.1.1.1.jar stax-api.jar wstx-asl.jar

建议在网络上使用这些罐子.我直接将它们复制到WEB-INF/lib文件夹中.我担心的一件事是路径问题,有人告诉我之前我应该​​通过右键单击类project-> build path然后添加jars添加一些jar.我也尝试过,不是一个好消息.我正在运行Tomcat7.0.网络也会运行到错误报告页面.请帮忙!

these jars are recommended on the web. I copied them directly to the WEB-INF/lib folder. One thing I'm worry about is the path issue, someone shown me before that I should add some jars by right click the class project->build path and then add jars. I tried it as well, not good news. I'm running Tomcat7.0. The web runs to a error report page as well.Please help!

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

I tried two local host link: 8080/Jersey/WEB-INF/web.xml & 8080/Jersey/rest/hello. both fail!

先谢谢了.

推荐答案

我怀疑这可能是StackOverflow上另一个问题的重复. Jersey当jersey-json时,不存在WebApplication提供程序添加依赖项

I suspect this may be a duplicate of another question on StackOverflow. Jersey No WebApplication provider is present when jersey-json dependency added

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

Ultimately, make sure that jersey-server is a dependency on your classpath. When you say "your jar file list", are you certain that these jars are in the web application's classpath? It may be a function of your IDE's build path that is causing your problems.

如果仍然有问题,请包括您使用的IDE以及类路径的配置方式.

If you still have issues, please include the IDE you use, along with how your classpath is configured.

这篇关于泽西岛:不存在WebApplication提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆