Last Updated on
A Java developer working with web app back-end development is required to have JavaEE development where the program design follows the RESTful architecture. To develop a RESTful application, follow useful tutorials and descriptions for JavaEE, choice of ServletContainers, framework description for developing RESTful web services such as Jersey, annotations that are used in a Java class for a JavaEE REST app, and the servlet naming and mapping in the project’s web.xml file. Some good tutorials that were beneficial to me were:
And some useful descriptions were:
At the time of preparing the Java RESTful app one should consider that the project’s Maven pom.xml file has the correct dependencies, as well as a right way to reference the application’s servlets in the web.xml file. One of the Maven dependencies that works as a ServletContainer and is the base for implementing a “Jax-RS with Jersey” is the jersey-container-servlet:
<dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet</artifactId> <version>2.29.1</version> </dependency>
The content of the web.xml file, which reference the Servlet being developed would then be:
<?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_3_0.xsd" id="WebApp_ID" version="3.0"> <servlet> <servlet-name>Jersey REST Service</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.javatpoint.rest</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey REST Service</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> </web-app>
The good tutorial at https://www.javatpoint.com/jax-rs-example-jersey has a more complete description.
If an error is encountered when deploying the application to the application server, one can search on StackOverflow and with links such as:
- What should be done in Tomcat error 404 – the origin server did not find current representation for the target resource or is not willing to disclose?
- Jersey stopped working with InjectionManagerFactory not found