Learn the powerful enterprise adaptable database:
Getting Started With ADABAS & Natural
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
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment