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

8 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
  3. This comment has been removed by the author.

    ReplyDelete
  4. IT Relocation Services
    WELCOME TO ANIKA TECH SUPPORT
    Anika Tech Support managed by a team of professionals utilising a combined 20+ years of experience in IT support and Managed IT services Focusing on Proactive support, continuity, growth and development. We are a forward thinking IT Company who support public and private sector using the latest tech as a driving force for our client’s Success.

    ReplyDelete
  5. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.mobile phone repair in Novi
    iphone repair in Novi
    cell phone repair in Novi
    phone repair in Novi
    tablet repair in Novi
    ipad repair in Novi
    mobile phone repair Novi
    iphone repair Novi
    cell phone repair Novi
    phone repair Novi


    ReplyDelete