2

i have following web.xml file.

<?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">
<display-name>SeekLocal</display-name>
<welcome-file-list>
  <welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
  <servlet-name>Resteasy</servlet-name>
  <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>Resteasy</servlet-name>
  <url-pattern>/*</url-pattern>
</servlet-mapping>
<context-param>
  <param-name>javax.ws.rs.Application</param-name>
  <param-value>com.ba.rs.webservices.LocalApplication</param-value>
</context-param>
<listener>
  <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
</web-app>

Now if i change url pattern from

<url-pattern>/*</url-pattern> to <url-pattern>/app/*</url-pattern>

it starts showing index.html but then i am not able to access the web services. i have searched internet and found that there are some filter which will be applied but i cannot find a complete solution. i tried by not changing the url pattern and applying a forwarder but still it didnt show index.html. guide me what should i do to change the url pattern of the application with index.html working. i am using container like below to add web services classes which is mentioned below.

package com.ba.rs.webservices;

import java.util.Set;
import java.util.HashSet;
import javax.ws.rs.core.Application;

public class LocalApplication extends Application {

  private Set<Object> singletons = new HashSet<Object>();
  private Set<Class<?>> empty = new HashSet<Class<?>>();
  public LocalApplication(){
    //add WS Classes in here.
     singletons.add(new UserWS());

}
@Override
public Set<Class<?>> getClasses() {
     return empty;
}
@Override
public Set<Object> getSingletons() {
     return singletons;
}

}

S0haib Nasir
  • 232
  • 2
  • 12

1 Answers1

2

i have solved the question by adding following lines in web.xml

<context-param>
  <param-name>resteasy.servlet.mapping.prefix</param-name>
  <param-value>/rest</param-value>
</context-param>

and changing the following

<url-pattern>/*</url-pattern> to <url-pattern>/rest/*</url-pattern>

thanks to @Nebelmann who answered similar question at the following link.

RESTEasy - @Path requiring a full path?

Community
  • 1
  • 1
S0haib Nasir
  • 232
  • 2
  • 12