Monday, March 11, 2019

Solution To: MyEclipse error while deploying JAX RS REST Web Service To Server


Problem: MyEclipse error while deploying JAX RS REST Web Service To Server

Error Message:
exception com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes. at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>

Solution:
Add <init-param> tag
(Assuming the project package is com.myeclipseide.ws)
.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <servlet>
  <display-name>JAX-RS REST Servlet</display-name>
  <servlet-name>JAX-RS REST Servlet</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.myeclipseide.ws</param-value> 
</init-param> 
  <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
  <servlet-name>JAX-RS REST Servlet</servlet-name>
  <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
.

Addition:
To test the REST URL, deploy the project to server, click the "Launch REST Web Services Explorer" button (the button is available in JavaEE Perspective window).
Based on the web.xml file above, the test url would be http://localhost:8080/restdemo/services/application.wadl (Assuming the project name is restdemo)

Reference:
https://www.genuitec.com/docs/web-services/developing-rest-web-service

4 comments:

  1. Thank you writer for sharing a very great knowledge here. I learn a lot more about your blog than I expected to & towards to continuing development of understanding of coding practice through your blog.
    Laptop service centre in chennai
    HP laptop service center in chennai
    Laptop display replacement in chennai
    Laptop Water damage service in chennai
    Macbook pro Water damage service in chennai
    Laptop screen replacement in chennai

    ReplyDelete
  2. capsa susun merupakan permainan yang sangat mudah dimenangkan karena tingkat winrate yang tinggi sehingga kamu tidak perlu khawatir dong dengan dana kamu meski kamu tidak hoky dalam permainan capsa kamu juga akan mendapatkan menang dalam beberapa ronde
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme
    hobiqq
    paito warna terlengkap
    Syair HK

    ReplyDelete