[英]Java RESTFUL-Service returns 500 Internal Server Error (jersey)
我有一個Java REST服務,它提供將JSON返回給客戶端的服務(使用Tomcat和Jersey)。 我一直在尋找這個問題好幾天了,但我真的不明白,因為服務器提供了另一個調用,該調用幾乎相同並且工作正常。...REST服務:
//working
@GET
@Path("/listAll")
@Produces({ MediaType.APPLICATION_JSON })
public List<Route> getAllRoutes() {
EntityManager em = getEntityManager();
Query q = em.createQuery("select r from Route r ");
@SuppressWarnings("unchecked")
List<Route> routeList = q.getResultList();
em.close();
return routeList;
}
MySQL表的“路點”包含3列:ID(BIGINT),COORDINATE(VARCHAR),ROUTEID(BIGINT)。 如果這很重要,則該項目將在Liferay上運行。...就像我說的那樣,我再也沒有f *****的想法了:/奇怪的是,“ / listAll”調用工作正常,但“ / getPoints”返回500,日志只說:
connection: 2015-01-13 18:10:47.715--ServerSession(27137311)--Thread(Thread[http-bio-8080-exec- 21,5,main])--client acquired: 18571860
[EL Finer]: transaction: 2015-01-13 18:10:47.715--ClientSession(18571860)--Thread(Thread[http-bio-8080-exec-21,5,main])--acquire unit of work: 32602042
[EL Finer]: transaction: 2015-01-13 18:10:47.715--UnitOfWork(32602042)--Thread(Thread[http-bio-8080-exec-21,5,main])--begin unit of work flush
[EL Finer]: transaction: 2015-01-13 18:10:47.715--UnitOfWork(32602042)--Thread(Thread[http-bio-8080-exec-21,5,main])--end unit of work flush
[EL Finest]: query: 2015-01-13 18:10:47.715--UnitOfWork(32602042)--Thread(Thread[http-bio-8080-exec-21,5,main])--Execute query ReadAllQuery(referenceClass=WayPoint sql="SELECT ID, ROUTEID, COORDINATE FROM WAYPOINT")
[EL Finest]: connection: 2015-01-13 18:10:47.715--ServerSession(27137311)--Connection(21934325)--Thread(Thread[http-bio-8080-exec-21,5,main])--Connection acquired from connection pool [default].
[EL Finest]: connection: 2015-01-13 18:10:47.715--ServerSession(27137311)--Connection(21934325)--Thread(Thread[http-bio-8080-exec-21,5,main])--Connection released to connection pool [default].
[EL Finer]: transaction: 2015-01-13 18:10:47.715--UnitOfWork(32602042)--Thread(Thread[http-bio-8080-exec-21,5,main])--begin unit of work commit
[EL Finer]: transaction: 2015-01-13 18:10:47.715--UnitOfWork(32602042)--Thread(Thread[http-bio-8080-exec-21,5,main])--end unit of work commit
[EL Finer]: transaction: 2015-01-13 18:10:47.715--UnitOfWork(32602042)--Thread(Thread[http-bio-8080-exec-21,5,main])--release unit of work
謝謝你們男孩/女孩;)
問候
在您的getter中為RouteId檢查Long-> long轉換。 如果RouteId為null,則在調用getter時存在一個隱式方法調用,以從Long轉換為long(通常在序列化為json期間發生)。 如果RouteId為null,則該方法調用將在框架代碼深處拋出NullPointerException,當該氣泡冒泡到容器時將變為500錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.