James MV
James MV

Reputation: 8717

Defining the correct resource path in web.xml?

I'm working through this tutorial: http://www.vogella.com/articles/REST/article.html#installation

And I don't understand the line where it says "This property must point to your resources classes." which is from this step:

5.3. Define Jersey Servlet dispatcher
You need to register Jersey as the servlet dispatcher for REST requests. Open the file web.xml and modify the file to the following.

<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>de.vogella.jersey.first</display-name>
  <servlet>
    <servlet-name>Jersey REST Service</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>de.vogella.jersey.first</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 parameter "com.sun.jersey.config.property.package" defines in which package jersey will look for the web service classes. This property must point to your resources classes. The URL pattern defines part of the base URL your application will be placed.

I've placed the jersey jars into my WEB-INF/lib folder. So can I use the path provided in the tutorial or should I use something else?

Upvotes: 0

Views: 1804

Answers (1)

condit
condit

Reputation: 10962

He's describing the com.sun.jersey.config.property.package property. This should be the package containing the REST resources in your project. This is unrelated to adding the Jersey library to your lib folder. He gets to this in section 7.3 of the tutorial. As long as you're putting your REST classes in the same package you can leave it as is.

Upvotes: 1

Related Questions