Roma Kap
Roma Kap

Reputation: 636

Tomcat, The requested resource is not available

i have some troubles with tomcat. I have simple REST-Service with Jersey/Tomcat. But my Get-Ressource could not be find and Post probably too.

My Code:

@Path("/NothificationListner")
public class NothificationListner {


    @GET
    @Consumes(MediaType.TEXT_PLAIN)
    public String pojo() {
        logger.info("[GET] REQUEST RECEIVED");
        return "[GET] pojo ok @ " + new Date().toString();
    }
}

My Web.xml

  <servlet>

        <servlet-name>jersey</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>jersey</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
       <servlet-name>jersey</servlet-name>
       <url-pattern>/*</url-pattern>
   </servlet-mapping>

I export my Project "myProg" as war-file into "C:\apache-tomcat-8.0.37\webapps\" Tomcat starts without errors. Tomcat creates folder "myProg", which contains everything:

myProg
  --META-INF
     -MANIFEST.MF
     -war-tracker
  --WEB-INF
     --classes/com/listner
       NothificationListner .class
       NothificationListner .java
  --lib
    "containts all libs for application"
    web.xml

And when i try to call: localhost:8080/myProg/NothificationListner I get 404, The requested resource is not available.

Upvotes: 1

Views: 1005

Answers (1)

Paul Samsotha
Paul Samsotha

Reputation: 208984

You're supposed to list the packages where your resource classes are here

<init-param>
    <param-name>jersey.config.server.provider.packages</param-name>
    <param-value>jersey</param-value>
</init-param>

I don't know what jersey is, but from your post, the listener is in the com.listner package. If you have other packages, you can separate them with a comma or semi-colon

Upvotes: 1

Related Questions