简体   繁体   English

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

[英]Java RESTFUL-Service returns 500 Internal Server Error (jersey)

i have a Java REST-Service which provides a service returning a JSON to the client (using Tomcat and Jersey). 我有一个Java REST服务,它提供将JSON返回给客户端的服务(使用Tomcat和Jersey)。 I have been searching for this problem for days now and i really don't get it, because there is another call provided by the server which is nearly the same and its working fine.... the REST service: 我一直在寻找这个问题好几天了,但我真的不明白,因为服务器提供了另一个调用,该调用几乎相同并且工作正常。...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;
}

The MySQL Table 'waypoint' contains 3 columns: ID(BIGINT), COORDINATE(VARCHAR), ROUTEID(BIGINT). MySQL表的“路点”包含3列:ID(BIGINT),COORDINATE(VARCHAR),ROUTEID(BIGINT)。 The project runs on Liferay if this is important....like i said, i have rly no f***** idea anymore :/ the strange thing is that the "/listAll" call works fine but "/getPoints" returns 500 and the log sais nothing but: 如果这很重要,则该项目将在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

thank u guys / girls ;) 谢谢你们男孩/女孩;)

greetings 问候

Check the Long->long conversion in your getter for RouteId. 在您的getter中为RouteId检查Long-> long转换。 If RouteId is null, there is an implicit method call to convert from Long to long when the getter is called (which generally happens during serialization to json). 如果RouteId为null,则在调用getter时存在一个隐式方法调用,以从Long转换为long(通常在序列化为json期间发生)。 If RouteId is null, that method call will kick out a NullPointerException somewhere deep in the framework code which will materialize as a 500 error when it bubbles up to the container. 如果RouteId为null,则该方法调用将在框架代码深处抛出NullPointerException,当该气泡冒泡到容器时将变为500错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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