将jersey与ejb集成后,我无法访问我的休息服务。
我用一只耳朵包部署了两个war和一个jar包。
一个战争包,我可以通过http://127.0.0.1:8080/web-1.0-SNAPSHOT/访问其服务,它将输出“ hello world, EJB
”;
另一个战争包,我无法通过http://127.0.0.1:8080/app-1.0-SNAPSHOT/services/hello
Here is the jar code.
@Stateless
public class SimpleStatelessEjb {
public String hello() {
return "hello world, EJB";
}
}
web-1.0-SNAPSHOT code
@WebServlet({"/", "/ejbServlet"})
public class EjbServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB
SimpleStatelessEjb statelessBean;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
PrintWriter writer = resp.getWriter();
String msg = statelessBean.hello();
writer.println(msg);
}
}
app-1.0-SNAPSHOT code
@ApplicationPath("services")
public class RestApplication extends ResourceConfig {
public RestApplication() {
// packages("individual.cc.app.servlet");
register(HelloController.class);
}
}
@Stateless
@Path("/hello/")
public class HelloController {
@EJB
SimpleStatelessEjb statelessBean;
@GET
@Produces(MediaType.APPLICATION_JSON)
public String hello() {
return statelessBean.hello();
}
}
我希望http://127.0.0.1:8080/app-1.0-SNAPSHOT/services/hello可以输出hello world, EJB
,但是它总是抛出Not Found
Here is the whole code
有人可以帮我吗?
非常感谢。