Hi, I’m trying to add an new rest endpoint to my xwiki extension
Following the exemple here https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiRESTfulAPI#HCustomresources
I can’t get it to works.
This is my code simplified ( First I just copy/paste the exact exemple provided by the doc but it didn’t work )
package eu.company.rest;
import javax.inject.Named;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.xwiki.component.annotation.Component;
import org.xwiki.rest.XWikiResource;
@Component
@Named("eu.company.rest.HelloWorldResource")
@Path("/hello")
@Singleton
class HelloWorldResource extends XWikiResource
{
@GET
@Produces(MediaType.TEXT_PLAIN)
public String get()
{
return "Hello there";
}
}
and it is declared in components.txt as
eu.company.rest.HelloWorldResource
I also tried @Component("eu.company.rest.HelloWorldResource")
without @Named
annotation, I also tried without the @Singleton
, it doesn t change anything
There is no error when I run the server, the component is well found .
When I try to access to http://localhost:8080/xwiki/
at the end of the xwiki loading I can see in the tomcat log a warning
The Class class eu.company.rest.HelloWorldResource is neither a provider nor a root resource class
Then when I try to access my endpoint at the url http://localhost:8080/xwiki/rest/hello
I get a 404 not found
Do you see something wrong ? Thanks
edit :
The warning seems to come from this code in restlet
Also we use
<parent>
<groupId>org.xwiki.contrib</groupId>
<artifactId>parent-platform-distribution</artifactId>
<version>10.6-1</version>
</parent>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-rest-server</artifactId>
<version>${commons.version}</version>
</dependency>