Re: [jetty-users] Unable to render Velocity Template
Sounds like the linux tmp folder is cleaned up every now and then. You can make jetty use a different tmp folder in order to prevent issue. See docs. Stefan 2015-01-28 12:26 GMT+01:00 Eduardo Fiss Beloni ebel...@voiza.com.br: Hello, We are having loads of Unable to render Velocity Template throughout the jetty logs. Then the user can't see the site anymore. 2015-01-26 10:20:38,751 [qtp399631128-23 ERROR CommonsLogger]: Unable to render Velocity Template, '/error.vm' org.apache.velocity.exception.VelocityException: Exception rendering #parse(/_inc/footer.vm) at /error.vm[line 67, column 9] ... ... 2015-01-25 23:07:34,732 [qtp1819130381-4849 ERROR CommonsLogger]: Unable to render Velocity Template, '/super/aba_vitrine.vm' org.apache.velocity.exception.VelocityException: VelocimacroProxy.render() : exception VM = #produto() It happens a few times a month. When this happens the only way to bring our frontend servers back is to restart jettys. This started to happen when we updated from jetty 7 to jetty 9.1.3. Could this be a jetty parameter or something? Thank you, Eduardo Fiss Beloni ebel...@voiza.com.br www.voiza.com.br Soluções em Java (51) 4063-8913 - Porto Alegre (53) 4062-9183/3222-1833 - Pelotas ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users -- BEKK Open http://open.bekk.no TesTcl - a unit test framework for iRules http://testcl.com ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
[jetty-users] Unable to render Velocity Template
Hello, We are having loads of Unable to render Velocity Template throughout the jetty logs. Then the user can't see the site anymore. 2015-01-26 10:20:38,751 [qtp399631128-23 ERROR CommonsLogger]: Unable to render Velocity Template, '/error.vm' org.apache.velocity.exception.VelocityException: Exception rendering #parse(/_inc/footer.vm) at /error.vm[line 67, column 9] ... ... 2015-01-25 23:07:34,732 [qtp1819130381-4849 ERROR CommonsLogger]: Unable to render Velocity Template, '/super/aba_vitrine.vm' org.apache.velocity.exception.VelocityException: VelocimacroProxy.render() : exception VM = #produto() It happens a few times a month. When this happens the only way to bring our frontend servers back is to restart jettys. This started to happen when we updated from jetty 7 to jetty 9.1.3. Could this be a jetty parameter or something? Thank you, Eduardo Fiss Beloni ebel...@voiza.com.br www.voiza.com.br Soluções em Java (51) 4063-8913 - Porto Alegre (53) 4062-9183/3222-1833 - Pelotas ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
Re: [jetty-users] Is there a way to avoid this?
Ah... looked at the code again, and modified it to set Content-Type and set the HTTP status code AFTER outputting the image. Duh. Rookie mistake. :) Steve Sobol - Lobos Studios wrote: There has to be a simple answer to this... I have a servlet that serves a PNG file if it exists, and if it doesn't, throws an HTTP 404 error and serves a default image. In the second case, I get the default image but I see this in the logs. I checked and couldn't find an obvious way to set the HTTP status code without committing the response... 2015-01-28 14:35:06.318:WARN:oejs.ServletHandler:/featured-event-image/event1-1.png java.lang.IllegalStateException: Committed at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1090) at org.eclipse.jetty.server.Response.reset(Response.java:1034) at com.mymitzvahdate.servlet.FeaturedEventImage.doGet(FeaturedEventImage.java:53) This is the servlet: package com.mymitzvahdate.servlet; import java.io.File; import java.io.IOException; import java.net.URLDecoder; import java.nio.file.Files; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.mymitzvahdate.Constants; import com.mymitzvahdate.persistence.Globals; public class FeaturedEventImage extends HttpServlet { public static final long serialVersionUID = 1L; // Properties - private String imagePath, defaultImagePath; // Actions protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { imagePath = Globals.get(Constants.GLOBAL_FEATURED_IMAGE_DIR); defaultImagePath = Globals.get(Constants.GLOBAL_DEFAULT_FEATURED_IMAGE); // Get requested image by path info. String requestedImage = request.getPathInfo(); // Check if file name is actually supplied to the request URI. if (requestedImage == null) { sendErrorAndDefaultPNG(response); } // Decode the file name String imageFilename = URLDecoder.decode(requestedImage, UTF-8); // chop off the extension if one exists if (imageFilename.lastIndexOf(.) -1) imageFilename = imageFilename.substring(0,imageFilename.lastIndexOf(.)); File image = new File(imagePath, imageFilename + .jpg); // Check if file actually exists in filesystem. if (!image.exists()) { sendErrorAndDefaultPNG(response); } response.reset(); sendImage(response, image); } private void sendImage(HttpServletResponse response, File image) { response.setContentType(image/png); response.setHeader(Content-Length, String.valueOf(image.length())); try { Files.copy(image.toPath(), response.getOutputStream()); } catch(IOException exc) { } } private void sendErrorAndDefaultPNG(HttpServletResponse response) { response.reset(); response.setStatus(HttpServletResponse.SC_NOT_FOUND); // 404. File errorImage = new File(imagePath, defaultImagePath); sendImage(response, errorImage); return; } } Thanks for whatever help you can offer -- Lobos Studios - Website and Mobile App Design Development; IT Support; Computer Maintenance Toll Free 877.919.4WEB - Apple Valley 760.684.8859 - Los Angeles 310.945.2410 www.LobosStudios.com * www.facebook.com/LobosStudios * @LobosStudios -- Lobos Studios - Website and Mobile App Design Development; IT Support; Computer Maintenance Toll Free 877.919.4WEB - Apple Valley 760.684.8859 - Los Angeles 310.945.2410 www.LobosStudios.com * www.facebook.com/LobosStudios * @LobosStudios ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
Re: [jetty-users] Is there a way to avoid this?
Correction: the servlet serves a JPEG if it exists, and if not, serves a default image which happens to be a PNG Steve Sobol - Lobos Studios wrote: There has to be a simple answer to this... I have a servlet that serves a PNG file if it exists, and if it doesn't, throws an HTTP 404 error and serves a default image. In the second case, I get the default image but I see this in the logs. I checked and couldn't find an obvious way to set the HTTP status code without committing the response... 2015-01-28 14:35:06.318:WARN:oejs.ServletHandler:/featured-event-image/event1-1.png java.lang.IllegalStateException: Committed at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1090) at org.eclipse.jetty.server.Response.reset(Response.java:1034) at com.mymitzvahdate.servlet.FeaturedEventImage.doGet(FeaturedEventImage.java:53) This is the servlet: package com.mymitzvahdate.servlet; import java.io.File; import java.io.IOException; import java.net.URLDecoder; import java.nio.file.Files; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.mymitzvahdate.Constants; import com.mymitzvahdate.persistence.Globals; public class FeaturedEventImage extends HttpServlet { public static final long serialVersionUID = 1L; // Properties - private String imagePath, defaultImagePath; // Actions protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { imagePath = Globals.get(Constants.GLOBAL_FEATURED_IMAGE_DIR); defaultImagePath = Globals.get(Constants.GLOBAL_DEFAULT_FEATURED_IMAGE); // Get requested image by path info. String requestedImage = request.getPathInfo(); // Check if file name is actually supplied to the request URI. if (requestedImage == null) { sendErrorAndDefaultPNG(response); } // Decode the file name String imageFilename = URLDecoder.decode(requestedImage, UTF-8); // chop off the extension if one exists if (imageFilename.lastIndexOf(.) -1) imageFilename = imageFilename.substring(0,imageFilename.lastIndexOf(.)); File image = new File(imagePath, imageFilename + .jpg); // Check if file actually exists in filesystem. if (!image.exists()) { sendErrorAndDefaultPNG(response); } response.reset(); sendImage(response, image); } private void sendImage(HttpServletResponse response, File image) { response.setContentType(image/png); response.setHeader(Content-Length, String.valueOf(image.length())); try { Files.copy(image.toPath(), response.getOutputStream()); } catch(IOException exc) { } } private void sendErrorAndDefaultPNG(HttpServletResponse response) { response.reset(); response.setStatus(HttpServletResponse.SC_NOT_FOUND); // 404. File errorImage = new File(imagePath, defaultImagePath); sendImage(response, errorImage); return; } } Thanks for whatever help you can offer -- Lobos Studios - Website and Mobile App Design Development; IT Support; Computer Maintenance Toll Free 877.919.4WEB - Apple Valley 760.684.8859 - Los Angeles 310.945.2410 www.LobosStudios.com * www.facebook.com/LobosStudios * @LobosStudios -- Lobos Studios - Website and Mobile App Design Development; IT Support; Computer Maintenance Toll Free 877.919.4WEB - Apple Valley 760.684.8859 - Los Angeles 310.945.2410 www.LobosStudios.com * www.facebook.com/LobosStudios * @LobosStudios ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
[jetty-users] Is there a way to avoid this?
There has to be a simple answer to this... I have a servlet that serves a PNG file if it exists, and if it doesn't, throws an HTTP 404 error and serves a default image. In the second case, I get the default image but I see this in the logs. I checked and couldn't find an obvious way to set the HTTP status code without committing the response... 2015-01-28 14:35:06.318:WARN:oejs.ServletHandler:/featured-event-image/event1-1.png java.lang.IllegalStateException: Committed at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1090) at org.eclipse.jetty.server.Response.reset(Response.java:1034) at com.mymitzvahdate.servlet.FeaturedEventImage.doGet(FeaturedEventImage.java:53) This is the servlet: package com.mymitzvahdate.servlet; import java.io.File; import java.io.IOException; import java.net.URLDecoder; import java.nio.file.Files; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.mymitzvahdate.Constants; import com.mymitzvahdate.persistence.Globals; public class FeaturedEventImage extends HttpServlet { public static final long serialVersionUID = 1L; // Properties - private String imagePath, defaultImagePath; // Actions protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { imagePath = Globals.get(Constants.GLOBAL_FEATURED_IMAGE_DIR); defaultImagePath = Globals.get(Constants.GLOBAL_DEFAULT_FEATURED_IMAGE); // Get requested image by path info. String requestedImage = request.getPathInfo(); // Check if file name is actually supplied to the request URI. if (requestedImage == null) { sendErrorAndDefaultPNG(response); } // Decode the file name String imageFilename = URLDecoder.decode(requestedImage, UTF-8); // chop off the extension if one exists if (imageFilename.lastIndexOf(.) -1) imageFilename = imageFilename.substring(0,imageFilename.lastIndexOf(.)); File image = new File(imagePath, imageFilename + .jpg); // Check if file actually exists in filesystem. if (!image.exists()) { sendErrorAndDefaultPNG(response); } response.reset(); sendImage(response, image); } private void sendImage(HttpServletResponse response, File image) { response.setContentType(image/png); response.setHeader(Content-Length, String.valueOf(image.length())); try { Files.copy(image.toPath(), response.getOutputStream()); } catch(IOException exc) { } } private void sendErrorAndDefaultPNG(HttpServletResponse response) { response.reset(); response.setStatus(HttpServletResponse.SC_NOT_FOUND); // 404. File errorImage = new File(imagePath, defaultImagePath); sendImage(response, errorImage); return; } } Thanks for whatever help you can offer -- Lobos Studios - Website and Mobile App Design Development; IT Support; Computer Maintenance Toll Free 877.919.4WEB - Apple Valley 760.684.8859 - Los Angeles 310.945.2410 www.LobosStudios.com * www.facebook.com/LobosStudios * @LobosStudios ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
Re: [jetty-users] Is there a way to avoid this?
Don't use response.reset() in your example. In your example error conditions ... if (requestedImage == null) { sendErrorAndDefaultPNG(response); } Just return from the doGet() and not worry about the reset. if (requestedImage == null) { sendErrorAndDefaultPNG(response); return; } -- Joakim Erdfelt joa...@intalio.com webtide.com http://www.webtide.com/ - intalio.com/jetty Expert advice, services and support from from the Jetty CometD experts eclipse.org/jetty - cometd.org On Wed, Jan 28, 2015 at 3:48 PM, Steve Sobol - Lobos Studios st...@lobosstudios.com wrote: There has to be a simple answer to this... I have a servlet that serves a PNG file if it exists, and if it doesn't, throws an HTTP 404 error and serves a default image. In the second case, I get the default image but I see this in the logs. I checked and couldn't find an obvious way to set the HTTP status code without committing the response... 2015-01-28 14:35:06.318:WARN:oejs.ServletHandler:/featured-event-image/event1-1.png java.lang.IllegalStateException: Committed at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1090) at org.eclipse.jetty.server.Response.reset(Response.java:1034) at com.mymitzvahdate.servlet.FeaturedEventImage.doGet(FeaturedEventImage.java:53) This is the servlet: package com.mymitzvahdate.servlet; import java.io.File; import java.io.IOException; import java.net.URLDecoder; import java.nio.file.Files; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.mymitzvahdate.Constants; import com.mymitzvahdate.persistence.Globals; public class FeaturedEventImage extends HttpServlet { public static final long serialVersionUID = 1L; // Properties - private String imagePath, defaultImagePath; // Actions protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { imagePath = Globals.get(Constants.GLOBAL_FEATURED_IMAGE_DIR); defaultImagePath = Globals.get(Constants.GLOBAL_DEFAULT_FEATURED_IMAGE); // Get requested image by path info. String requestedImage = request.getPathInfo(); // Check if file name is actually supplied to the request URI. if (requestedImage == null) { sendErrorAndDefaultPNG(response); } // Decode the file name String imageFilename = URLDecoder.decode(requestedImage, UTF-8); // chop off the extension if one exists if (imageFilename.lastIndexOf(.) -1) imageFilename = imageFilename.substring(0,imageFilename.lastIndexOf(.)); File image = new File(imagePath, imageFilename + .jpg); // Check if file actually exists in filesystem. if (!image.exists()) { sendErrorAndDefaultPNG(response); } response.reset(); sendImage(response, image); } private void sendImage(HttpServletResponse response, File image) { response.setContentType(image/png); response.setHeader(Content-Length, String.valueOf(image.length())); try { Files.copy(image.toPath(), response.getOutputStream()); } catch(IOException exc) { } } private void sendErrorAndDefaultPNG(HttpServletResponse response) { response.reset(); response.setStatus(HttpServletResponse.SC_NOT_FOUND); // 404. File errorImage = new File(imagePath, defaultImagePath); sendImage(response, errorImage); return; } } Thanks for whatever help you can offer -- Lobos Studios - Website and Mobile App Design Development; IT Support; Computer Maintenance Toll Free 877.919.4WEB - Apple Valley 760.684.8859 - Los Angeles 310.945.2410 www.LobosStudios.com * www.facebook.com/LobosStudios * @LobosStudios ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
Re: [jetty-users] Is there a way to avoid this?
That actually worked. The solution I thought I had, didn't work. :) Thanks Joakim Erdfelt wrote: Don't use response.reset() in your example. In your example error conditions ... if (requestedImage == null) { sendErrorAndDefaultPNG(response); } Just return from the doGet() and not worry about the reset. if (requestedImage == null) { sendErrorAndDefaultPNG(response); return; } -- Joakim Erdfelt joa...@intalio.com mailto:joa...@intalio.com webtide.com http://www.webtide.com/ - intalio.com/jetty http://intalio.com/jetty Expert advice, services and support from from the Jetty CometD experts eclipse.org/jetty http://eclipse.org/jetty/ - cometd.org http://cometd.org/ On Wed, Jan 28, 2015 at 3:48 PM, Steve Sobol - Lobos Studios st...@lobosstudios.com mailto:st...@lobosstudios.com wrote: There has to be a simple answer to this... I have a servlet that serves a PNG file if it exists, and if it doesn't, throws an HTTP 404 error and serves a default image. In the second case, I get the default image but I see this in the logs. I checked and couldn't find an obvious way to set the HTTP status code without committing the response... 2015-01-28 14:35:06.318:WARN:oejs.ServletHandler:/featured-event-image/event1-1.png java.lang.IllegalStateException: Committed at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1090) at org.eclipse.jetty.server.Response.reset(Response.java:1034) at com.mymitzvahdate.servlet.FeaturedEventImage.doGet(FeaturedEventImage.java:53) This is the servlet: package com.mymitzvahdate.servlet; import java.io.File; import java.io.IOException; import java.net.URLDecoder; import java.nio.file.Files; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.mymitzvahdate.Constants; import com.mymitzvahdate.persistence.Globals; public class FeaturedEventImage extends HttpServlet { public static final long serialVersionUID = 1L; // Properties - private String imagePath, defaultImagePath; // Actions protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { imagePath = Globals.get(Constants.GLOBAL_FEATURED_IMAGE_DIR); defaultImagePath = Globals.get(Constants.GLOBAL_DEFAULT_FEATURED_IMAGE); // Get requested image by path info. String requestedImage = request.getPathInfo(); // Check if file name is actually supplied to the request URI. if (requestedImage == null) { sendErrorAndDefaultPNG(response); } // Decode the file name String imageFilename = URLDecoder.decode(requestedImage, UTF-8); // chop off the extension if one exists if (imageFilename.lastIndexOf(.) -1) imageFilename = imageFilename.substring(0,imageFilename.lastIndexOf(.)); File image = new File(imagePath, imageFilename + .jpg); // Check if file actually exists in filesystem. if (!image.exists()) { sendErrorAndDefaultPNG(response); } response.reset(); sendImage(response, image); } private void sendImage(HttpServletResponse response, File image) { response.setContentType(image/png); response.setHeader(Content-Length, String.valueOf(image.length())); try { Files.copy(image.toPath(), response.getOutputStream()); } catch(IOException exc) { } } private void sendErrorAndDefaultPNG(HttpServletResponse response) { response.reset(); response.setStatus(HttpServletResponse.SC_NOT_FOUND); // 404. File errorImage = new File(imagePath, defaultImagePath); sendImage(response, errorImage); return; } } Thanks for whatever help you can offer -- Lobos Studios - Website and Mobile App Design Development; IT Support; Computer Maintenance Toll Free 877.919.4WEB - Apple Valley 760.684.8859 tel:760.684.8859 - Los Angeles 310.945.2410 tel:310.945.2410 www.LobosStudios.com http://www.LobosStudios.com * www.facebook.com/LobosStudios http://www.facebook.com/LobosStudios * @LobosStudios ___ jetty-users mailing list jetty-users@eclipse.org mailto:jetty-users@eclipse.org To change your delivery options, retrieve
[jetty-users] AsyncContentProvider under-documented
I need to implement an AsyncContentProvider, but the contract for this interface appears to be significantly under-documented. When available content has been exhausted, DeferredContentProviderIterator.next() returns null, so this is presumably part of the contract. DeferredContentProviderIterator implements Callback, but the contract for this is nowhere mentioned. Is this part of the ContentProvider contract like Closeable is, or is this specific to AsyncContentProvider? Is Callback a required or optional interface on AsyncContentProvider iterators? It appears to expect to have succeeded() or failed() called for every ByteBuffer returned from next(), including nulls, is this correct? Is there an additional succeeded()/failed() call after the iterator indicates no more elements? DeferredContentProvider appears to notify the Listener once for each (non-null) ByteBuffer plus once when closed. (Except not after failed() is called.) Is this necessary, or would it be sufficient to notify once after each time next() returns null, possibly also needing once when the first ByteBuffer is available? ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users