0
I have the following code that provides my portal with the images that are in the database
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String id = req.getParameter("id");
if(id.equals("logo")){
resp.setContentType(museu.getConfiguracao().getContentTypeLogo());
resp.getOutputStream().write(museu.getConfiguracao().getLogo());
}else if(req.getParameter("slide")!=null){
resp.setContentType(banco.getSlide(id).getContentType());
resp.getOutputStream().write(banco.getSlide(id).getContent());
}
else{
Foto foto = museu.getFoto(Long.parseLong(id));
resp.setContentType(foto.getContentType());
resp.getOutputStream().write(foto.getContent());
}
}
The problem, when I try to request 3/4 or more images to the same page, the application server (Glassfish) simply "hangs" and after a while releases the error, the images are usually loaded a little (about 10%, another 50%) but simply the server "hangs" out of nowhere. Headers of Log Errors:
2014-03-21T08:58:20.561-0300|Grave: java.io.IOException: java.util.concurrent.TimeoutException
at org.glassfish.grizzly.utils.Exceptions.makeIOException(Exceptions.java:81)
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:201)
at org.glassfish.grizzly.http.io.OutputBuffer.blockAfterWriteIfNeeded(OutputBuffer.java:951)
... 36 more
2014-03-21T08:58:20.567-0300|Advertência: StandardWrapperValve[MultiMidiaServlet]: Servlet.service() for servlet MultiMidiaServlet threw exception
java.io.IOException: java.util.concurrent.TimeoutException
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:201)
at org.glassfish.grizzly.http.io.OutputBuffer.blockAfterWriteIfNeeded(OutputBuffer.java:951)
... 36 more
these requests you are making, are for the same image? Have you considered using a cache, not to read the image stream in every request?
– Miguel Cartagena
They are for different images, up to 3 images works normally, make a cache as?
– Paulo
Then I was able to "solve" the problem, it seemed to be a bug in Grizzly , a glassfish module that manages the contents of Servlet, I got a server release in the repository that has a more authenticated version of Grizzly and no longer occurs the problem :)
– Paulo