WARNING: The (sub)resource method contains empty path annotation

15,849

The warning means you have a resource method annotated with @Path("/") or @Path(""). For instance

@Path("test")
public class Test {

    @GET
    @Path("/")
    public String test(){}
}

Not sure why Jersey would give a warning, maybe just to make sure that's what you really want. The reason is that a resource method with @Path("/") is redundant, as it's already implied if you were just to do

@Path("test")
public class Test {

    @GET
    public String test(){}
}

without the @Path("/"). It works the same. So if you have these, remove them, and it should take away the warnings.

Share:
15,849
Brisi
Author by

Brisi

Updated on June 14, 2022

Comments

  • Brisi
    Brisi almost 2 years

    I have configured rest path like "/v1/" and the endpoint configured in servlet like '/test/'.

    Now I removed the "/v1" from the java class "Test".

    org.glassfish.jersey.internal.Errors logErrors
    WARNING: The following warnings have been detected: WARNING: The (sub)resource method test in com.abc.services.Test contains empty path annotation.
    

    I got the above warning after make this change. How to handle this warning?

    And I want this "/v1" removing changes for across 10 rest paths. So anyone help me to run without warnings?