Clara Clara - 1 year ago 74
Java Question

Empty rest path config, cant access app page

I configured restEasy for creating api services in my java application, as follows

Added dependencies in pom




Created a rest config class as follows,

public class RestClass extends Application {
private Set<Object> singletons = new HashSet<Object>();

public RestClass() {
singletons.add(new Stimulant());

public Set<Object> getSingletons() {
return singletons;

This is my service class which provides json data,

@Path(value = "/")
public class Stimulant {

@Path(value = "/{param}")
public Response getMsg(@PathParam(value = "param") String appId) {
String token = documentDAO.mobileAppToken(appId);
return Response.status(200).entity(token).build();

I am able to get the json data while hitting the url

Problem is When I am accessing my app's home page, it doesn't shows the page (
). It went to api call instead of opening app home page.

How do I come out from this problem?

Answer Source

You should do this with Filter servlet.

Let us continue with your rest config as "/f". When hitting url in browser you can remove the /f and forward your request with appending the "/f" where it needs.

simple code,

public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
        if (request instanceof HttpServletRequest) {
        String path = ((HttpServletRequest) request).getServletPath();
        String newPath = null;

                newPath = "f" + path;

        } else {
            newPath = path;
        request.getRequestDispatcher(newPath).forward(request, response);
    chain.doFilter(request, response);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download