Harshit
Harshit

Reputation: 1217

How to create simple Jersey app without using Maven

I wanted to make a simple Jersey-based REST app without using Maven in NetBeans. I followed the following steps and now I am stuck:

  1. Created a simple web app using NetBeans (or any other development IDE).
  2. Added JAX-RS libraries to my project.
  3. I don't have web.xml present since I am using org.netbeans.rest.application.config.

I am stuck now. I want to use web.xml. Is there any alternative?

P.S. - I am trying to use JSON as input without using Maven.

Upvotes: 1

Views: 1535

Answers (1)

user647772
user647772

Reputation:

Since in your third step you've created the configuration class to expose your JAX-RS Resource classes, you don't need the functionality in web.xml. Your application should be ready to run, at least on Glassfish or another Java server.

The whole idea of Java EE 6 is to get rid of XML configuration files like the web.xml. New annotations like @javax.servlet.annotation.WebServlet and @javax.ws.rs.ApplicationPath are used to configure Servlets and REST applications.

But if you want to have a web.xml, you can create one in the directory web/WEB-INF. A minimal web.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
         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_3_0.xsd">
</web-app>

Upvotes: 1

Related Questions