Buggy code:
@ RequestMapping ( value = "//crawls//{id}//delete" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public boolean deleteCrawlingJob ( @ PathVariable ( "id" ) String id ) throws RevealException { } @ RequestMapping ( value = "//crawls//{id}//stop" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public CrawlJob cancelCrawlingJob ( @ PathVariable ( "id" ) String id ) { } @ RequestMapping ( value = "//crawls//{id}//status" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public CrawlStatus getCrawlingJobStatus ( @ PathVariable ( "id" ) String id ) { } @ RequestMapping ( value = "//crawls//status" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public List < Responses . CrawlStatus > getCrawlerStatus ( ) { } @ RequestMapping ( value = "//collections//add" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public IndexResponse collectionsAdd ( @ RequestParam ( value = "name" , required = true ) String name , @ RequestParam ( value = "size" , required = false , defaultValue = "100000" ) int numVectors ) { } @ RequestMapping ( value = "//media//{collection}" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public MediaResponse mediaItemsV2 ( @ RequestParam ( value = "count" , required = false , defaultValue = "10" ) int count , @ RequestParam ( value = "offset" , required = false , defaultValue = "0" ) int offset , @ RequestParam ( value = "type" , required = false ) String type , @ PathVariable ( "collection" ) String collection ) { } @ RequestMapping ( value = "//media//{collection}//{id}" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public Media mediaItemByIdV2 ( @ PathVariable ( "collection" ) String collection , @ PathVariable ( "id" ) String id ) { } @ RequestMapping ( value = "//media//{collection}//search" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public MediaResponse mediaItemsSearchV2 ( @ PathVariable ( "collection" ) String collection , @ RequestParam ( value = "date" , required = false , defaultValue = "-1" ) long date , @ RequestParam ( value = "w" , required = false , defaultValue = "0" ) int w , @ RequestParam ( value = "h" , required = false , defaultValue = "0" ) int h , @ RequestParam ( value = "count" , required = false , defaultValue = "10" ) int count , @ RequestParam ( value = "offset" , required = false , defaultValue = "0" ) int offset , @ RequestParam ( value = "query" , required = false ) String query , @ RequestParam ( value = "type" , required = false ) String type ) { } private List < Responses . SimilarityResponse > simList2 ; private String lastImageUrl2 ; private double lastThreshold2 ; private boolean isBusy2 = false ; @ RequestMapping ( value = "//media//{collection}//similar" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public List < Responses . SimilarityResponse > findSimilarImagesV2 ( @ PathVariable ( "collection" ) String collectionName , @ RequestParam ( value = "imageurl" , required = true ) String imageurl , @ RequestParam ( value = "offset" , required = false , defaultValue = "0" ) int offset , @ RequestParam ( value = "count" , required = false , defaultValue = "50" ) int count , @ RequestParam ( value = "threshold" , required = false , defaultValue = "0.6" ) double threshold ) { } @ RequestMapping ( value = "//media//{collection}//cluster" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public boolean clusterCommandIncremental ( @ PathVariable ( "collection" ) String collection , @ RequestParam ( value = "eps" , required = true , defaultValue = "1.0" ) double eps , @ RequestParam ( value = "minpoints" , required = true , defaultValue = "3" ) int minpoints , @ RequestParam ( value = "count" , required = true , defaultValue = "1000" ) int count ) { } private List < Cluster < RevealController . ClusterableMedia > > existingClusters ; class ClusterRunner implements Runnable { private String collection ; private int count ; private double eps ; private int minpoints ; ClusterRunner ( String collection , int count , double eps , int minpoints ) { } @ Override public void run ( ) { } } @ RequestMapping ( value = "//clusters//{collection}" , method = RequestMethod . GET , produces = "application//json" ) @ ResponseBody public List < gr . iti . mklab . simmo . core . cluster . Cluster > getClusters ( @ PathVariable ( "collection" ) String collection , @ RequestParam ( value = "offset" , required = false , defaultValue = "0" ) int offset , @ RequestParam ( value = "count" , required = false , defaultValue = "50" ) int count ) { DAO < gr . iti . mklab . simmo . core . cluster . Cluster , String > clusterDAO = new org . mongodb . morphia . dao . BasicDAO ( Cluster . class , MorphiaManager . getMongoClient ( ) , MorphiaManager . getMorphia ( ) , MorphiaManager . getDB ( collection ) . getName ( ) ) ; <START_BUG> return clusterDAO . getDatastore ( ) . find ( Cluster . class ) . offset ( offset ) . limit ( count ) . asList ( ) ; <END_BUG> } private static class ClusterableMedia extends Media implements Clusterable { private double [ ] vector ; private Media item ; public ClusterableMedia ( Media item , double [ ] vector ) { } @ Override public double [ ] getPoint ( ) { } } @ ResponseStatus ( HttpStatus . INTERNAL_SERVER_ERROR ) @ ExceptionHandler ( RevealException . class ) @ ResponseBody public RevealException handleCustomException ( RevealException ex ) { } public static void main ( String [ ] args ) throws Exception { } No newline ; at end ;

Fix:
return clusterDAO . getDatastore ( ) . find ( Cluster . class ) . order ( "-size" ) . offset ( offset ) . limit ( count ) . asList ( ) ;