Reputation: 964
I'm using JBoss 9.x Application Server and I want to create a REST api to communicate with my EJBs. I created two classes PlayerRestApi and PlayerEJB and deploy it to wildfly, but when I requested /player the response is always 404.
Note: I will post the PlayerRestApi class with a dummy return.
PlayerRestApi code:
@Local
@Path("/player")
@Consumes("application/json")
@Produces("application/json")
public class PlayerRestApi{
PlayerEJB player;
@GET
public Map<String, String> getPlayer(){
Map<String, String> r = new HashMap<String,String>();
r.put("Name","Ronaldo");
return r;
}
}
When I tried this route, localhost: http://localhost:28070/appname/player Wildfly returns 404.
Upvotes: 1
Views: 1019
Reputation: 964
I was deploying a jar file instead of a war file, so the wildfly returns 404. The code it's correct and works.
Note This version of Wildfly Application Server doesn't need the web.xml file.
Upvotes: 1
Reputation: 2468
You need to use for example RESTEasy libraries, I don´t know if wildfly has it out of the box (is a jboss library), you can use Jersey too.
¿Have you updated your web.xml in order to define the RESTEasy servlets?
Here is an example (you have to put your class in resteasy.resources)
<context-param>
<param-name>resteasy.resources</param-name>
<param-value>your JAX-RS annotated class</param-value>
</context-param>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Upvotes: 1