I am trying to create a Java EE application utilizing JX-RS. I have got it working using the following configuration:
@ApplicationPath("rs")
public class MyApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
final Set<Class<?>> classes = new HashSet<>();
// register root resource
classes.add(ProbeREST.class);
return classes;
}
}
However, I would much prefer to use web.xml for the configuration. I think the above is very ugly in comparison to a simple xml configuration, like so:
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet-mapping>
<servlet-name>javax.ws.rs.core.Application</servlet-name>
<url-pattern>/rs/*</url-pattern>
</servlet-mapping>
</web-app>
Unfortunately, when I try to deploy the application, I receive the error:
Exception while deploying the app [my_app] : There is no web component by the name of javax.ws.rs.core.Application here.
How can I prevent this error?