繁体   English   中英

Java RESTFUL-Service返回500 Internal Server Error(球衣)

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM