i’m currently trying to stream a video file over Jersey REST service and get a mysterious exception on returning the response:
ERROR WebApplicationImpl - The RuntimeException could not be mapped to a response, re-throwing to the HTTP container java.lang.NullPointerException
at com.sun.jersey.core.util.KeyComparatorHashMap$Entry.hashCode(KeyComparatorHashMap.java:735)
at java.util.HashMap.getEntry(HashMap.java:344)
at java.util.HashMap.containsKey(HashMap.java:335)
at java.util.HashSet.contains(HashSet.java:184)
at com.sun.jersey.server.linking.impl.RefProcessor.processLinks(RefProcessor.java:85)
at com.sun.jersey.server.linking.impl.RefProcessor.processMember(RefProcessor.java:120)
at com.sun.jersey.server.linking.impl.RefProcessor.processLinks(RefProcessor.java:113)
at com.sun.jersey.server.linking.impl.RefProcessor.processMember(RefProcessor.java:120)
at com.sun.jersey.server.linking.impl.RefProcessor.processLinks(RefProcessor.java:113)
at com.sun.jersey.server.linking.impl.RefProcessor.processMember(RefProcessor.java:120)
....
The code creating the response looks like follows:
return Response.ok( new StreamingOutput( )
{
@Override
public void write( OutputStream output ) throws WebApplicationException
{
PrintWriter out = new PrintWriter( output );
out.println( "Foo" );
out.close( );
}
}, MediaType.MULTIPART_FORM_DATA ).build( );
(I already deleted additional range headers and stuff). I have several breakpoints in the StreamingOutput.write() method, but none seems to be reached. I have a second rest method returning the video as complete entity which works.
So, has anybody an ideo what the exception means and what can i improve? Thanks!
OK, problem is that the Jersey LinkFilter gets an exception parsing StreamingOutput. My solution was to write my own LinkFilter extending the existing one like follows: