java - Allocate exception for servlet Jersey REST Service Error -


i'm re-coding webservice i've created can create "how-to" git other members of group taking on project.

this time around, started error when trying use webservice , can't seem find problem because code looks i've coded (a code worked).

i using apache tomcat , jersey json.

here error:

mai 14, 2015 6:08:02 pm org.apache.catalina.core.standardwrappervalve invoke severe: allocate exception servlet jersey rest service com.sun.jersey.api.container.containerexception: resourceconfig instance not contain root resource classes. @ com.sun.jersey.server.impl.application.rootresourceurirules.<init>(rootresourceurirules.java:99) @ com.sun.jersey.server.impl.application.webapplicationimpl._initiate(webapplicationimpl.java:1359) @ com.sun.jersey.server.impl.application.webapplicationimpl.access$700(webapplicationimpl.java:180) @ com.sun.jersey.server.impl.application.webapplicationimpl$13.f(webapplicationimpl.java:799) @ com.sun.jersey.server.impl.application.webapplicationimpl$13.f(webapplicationimpl.java:795) @ com.sun.jersey.spi.inject.errors.processwitherrors(errors.java:193) @ com.sun.jersey.server.impl.application.webapplicationimpl.initiate(webapplicationimpl.java:795) @ com.sun.jersey.server.impl.application.webapplicationimpl.initiate(webapplicationimpl.java:790) @ com.sun.jersey.spi.container.servlet.servletcontainer.initiate(servletcontainer.java:509) @ com.sun.jersey.spi.container.servlet.servletcontainer$internalwebcomponent.initiate(servletcontainer.java:339) @ com.sun.jersey.spi.container.servlet.webcomponent.load(webcomponent.java:605) @ com.sun.jersey.spi.container.servlet.webcomponent.init(webcomponent.java:207) @ com.sun.jersey.spi.container.servlet.servletcontainer.init(servletcontainer.java:394) @ com.sun.jersey.spi.container.servlet.servletcontainer.init(servletcontainer.java:577) @ javax.servlet.genericservlet.init(genericservlet.java:212) @ org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1213) @ org.apache.catalina.core.standardwrapper.allocate(standardwrapper.java:827) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:129) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:127) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:293) @ org.apache.coyote.http11.http11processor.process(http11processor.java:861) @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:606) @ org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:489) @ java.lang.thread.run(unknown source)

here web.xml file:

<?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" 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>com.labtabdb.rest</display-name> <welcome-file-list>   <welcome-file>readme.html</welcome-file>      <welcome-file>index.html</welcome-file>   <welcome-file>index.htm</welcome-file>   <welcome-file>index.jsp</welcome-file>   <welcome-file>default.html</welcome-file>   <welcome-file>default.htm</welcome-file>   <welcome-file>default.jsp</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>com.labtabdb.rest</param-value>     </init-param>   <load-on-startup>1</load-on-startup>  </servlet>  <servlet-mapping>    <servlet-name>jersey rest service</servlet-name>    <url-pattern>/nxp/*</url-pattern>  </servlet-mapping>  </web-app> 

here class uses @path annotation:

//url path class it's methods/chemin url pour la classe et ses methodes @path ("/v1/inventory")  public class v1__inventory {   @get //url ending in /v1/inventory /chemin terminé par /v1/inventory @produces(mediatype.application_json)  public response errorifnoqueryparamspecified() throws exception {         return response                 .status(400) //bad request                 .entity("error: please specify extension , parameter search.")                  .build(); }  /**  * method returns materials filter material name  * @param material name  * @return response  * @throws exception  */  @path("/{material_label}")  @get @produces(mediatype.application_json) public response returnmaterial(@pathparam("material_label") string material) throws exception {      material = urldecoder.decode(material, "utf-8"); //decode url param     string returnstring = null;     jsonarray json;      try     {             json = labtab_mysqlquerys                  .getmaterialsbyname(material);          //if there no results query         if(json.length() == 0)              throw new customexception("no results returned");         else //otherwise return results             returnstring = json.tostring();      }     catch(customexception e)     {         return response                 .status(204)                 .entity(e.getmessage())                 .build();     }     catch (exception e)     {         e.printstacktrace();         return response                 .status(500) //internal server error                 .entity("server not able process request")                 .build();     }      return response             .ok(returnstring)             .build(); } 

i've been searching , reading same articles on , on 3 days , have yet find solution solves error.

all appreciated

i'm going go ahead , respond own question in hopes helps new rest.

i made pretty stupid mistake while creating tutorial: "url" web service was, example, com.webservice.rest. when re-doing project, decided change names of packages correspond new url: class had path annotation, let's say, @path ("/v1/inventory") changed com.webservice.inventory.

when typing new package name, rushed , forgot include word rest in com.webservice.rest.inventory .

when programming webservice, have remember make sure the prefix of each package containing path annotation url of web service.


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -