messerbill
messerbill

Reputation: 5629

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). 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:

//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). 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:

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

Upvotes: 0

Views: 4776

Answers (1)

Ryan
Ryan

Reputation: 151

Check the Long->long conversion in your getter for RouteId. 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). 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.

Upvotes: 1

Related Questions