【发布时间】:2015-11-30 12:17:26
【问题描述】:
添加以下代码后:
@GET
@Produces({"application/xml", "application/json"})
public WatchList find(@PathParam("id") Integer id) {
WatchList results = em.createNamedQuery("WatchList.findById", WatchList.class)
.setParameter("id", id)
.getSingleResult();
return results;
}
@GET
@Path("{id}")
@Produces(MediaType.TEXT_HTML)
public void findById(
@Context final HttpServletRequest request,
@Context final HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/jsp/AMLManagement.jsp");
request.setAttribute("items", find("id"));
dispatcher.forward(request, response);
}
我收到了错误Severe: WebModule[/MavenProjectTest]StandardWrapper.Throwable
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
还有这个:Severe: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
有人知道如何解决这个问题吗?我在上面的代码中做错了什么导致了这个错误吗?
【问题讨论】:
-
还有更多的堆栈跟踪吗?还有什么让您认为您发布的代码与它有任何关系?
-
@peeskillet 我在添加此代码后立即收到此错误,我之前没有问题
-
对于
find方法,您不需要@Path吗? -
@asgs 我不知道,我在我的 findAll 上做了同样的事情,但是我有一个“@override”,但这对这个不起作用,我没有知道为什么
标签: java rest maven jsp jax-rs