Can I create a leisure service with an interface and an implementation class? and all JAX-RS imports go into the interface? I am using jersey2.4 and jetty8.1.
here is my interface:
MyService.java
package foo.bar; @Path("/abc") public interface MyService { @GET @JSONP @Path("/method/{id}") public MyResponse getStuff(@PathParam("id") Integer id); }
MyServiceImpl.java
package foo.bar.impl; public class MyServiceImpl implements MyService { public MyServiceImpl() {} @Override public MyResponse getStuff(Integer id) {
here is my web.xml:
<servlet> <servlet-name>Scivantage REST Service</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>foo.bar</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
I registered this service provider package (foo.bar), but it complains about this: javax.servlet.ServletException: MultiException has 1 exception. This is: | 1. java.lang.NoSuchMethodException: Could not find a suitable constructor in class foo.bar.MyService. |
When I tried with the implementation class package (foo.bar.impl), it complains about this: I get HTTP ERROR 404; doing nothing; no exceptions on the console
When I tried both, he complains the same as above:
javax.servlet.ServletException: MultiException has 1 exception. This is: | 1. java.lang.NoSuchMethodException: Could not find a suitable constructor in class foo.bar.MyService. |
You can help? What am I doing wrong?
source share