Search code examples
tomcatjersey

Jersey: No WebApplication provider is present


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)

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>

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

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!

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

Thanks in advance.


Solution

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

    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.

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