Please see codes below. I can visit http://localhost:8080/messengerdemo/messages and interact with all the APIs but every time I access http://localhost:8080/messengerdemo/profiles I got a 404 not found error. What did I do wrong? I am a beginner and trying to learn jersey and REST API.
web.xml
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.learn.rest.messengerdemo.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Message resources
@Path("/messages")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class MessageResource {
MessageService messageService = new MessageService();
@GET
public List<Message> getMessages() {
return messageService.getAllMessages();
}
}
Profile resources.
@Path("/profiles")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class ProfileResource {
private ProfileService profileservice = new ProfileService();
@GET
public List<Profile> getAllProfiles() {
return profileservice.getAllProfiles();
}
}