I have created simple 3 files in Java, and used mvn clean package wildfly:deploy command to run it. It all deployed successfully (at least thats what is written in console). However, when I go to
http://localhost:8080/lab-rest-api/library/book
I get 404 error. My project is located in module lab-rest-api (its just a part of a project, other modules are for web consume - ejb, ear etc)
I did web service and simple web consuming and it worked out fine. However, REST API is not working.
Here is my pom.xml:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.6.3.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.6.3.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>3.6.3.Final</version>
<scope>provided</scope>
</dependency>
My extend Application:
@ApplicationPath("/")
public class RESTMain extends Application {
public RESTMain() {
System.out.println("whatever");
}
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(ServicesInterface.class);
return classes;
}
}
And my service:
@Path("/library")
@Consumes({"application/json"})
@Produces({"application/json"})
public class ServicesInterface {
Book booky = new Book();
@GET
@Path("/book/{title}")
public Book getBook(@PathParam("title") String title){
return booky;
}
@PUT
@Path("/book/{title}")
public Book addBook(@PathParam("title") String title, @QueryParam("author") String author){
return booky;
}
@POST
@Path("/book/{title}")
public Book updateBook(@PathParam("title") String title, String author){
return booky;
}
@DELETE
@Path("/book/{title}")
public Book removeBook(@PathParam("title") String title){
return booky;
}
}
"Book" is a simple class with 2 Strings (author and title) and getters and setters for it.