Please create a ticket with a quickstart and we will take a look.
Thanks!

On Fri, Aug 16, 2013 at 12:48 PM, Hans Lesmeister <
[email protected]> wrote:

> Seems the code didn't make it:
>
> Hi all,
>
> To deliver resources (mainly images) dynamically, we have created a custom
> ResourceReference and mounted that to a path:
>
>   // in our Application.init():
>   mountResource("assets/${path}/${name}, new CustomResourceReference());
>
>   // in CustomResourceReference:
>       public IResource getResource() {
>         return new AbstractResource() {
>             @Override
>             protected ResourceResponse newResourceResponse(Attributes
> attributes) {
>                 // (slightly simplified for readability)
>                 final String folder = parameters.get("folder").toString();
>                 final String folder = parameters.get("name").toString();
>
>                 ResourceResponse response = new ResourceResponse();
>                 response.setWriteCallback(new WriteCallback() {
>                     @Override
>                     public void writeData(Attributes attributes) throws
> IOException {
>                         InputStream stream = null;
>                         try {
>                             log.debug("Getting stream for {}/{}", folder,
> name);
>                             stream =
> ourService.createStreamFromPath(folder,
> name);
>                             if (stream == null) {
>                                 log.debug("Stream for {}/{} could not be
> retrieved. Returning 404", folder, name);
>                                 throw new
> AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND);
>                             }
>                             log.debug("Writing stream", folder, name);
>                             writeStream(attributes, stream);
>                         } finally {
>                             IOUtil.close(stream);
>                         }
>
>                     }
>                 });
>                 return response;
>             }
>         };
>     }
>
> As long as the image is there and an inputstream can be retrieved from our
> service, everything works fine. However if a stream is not available, we
> throw an AbortException 404. In that case later on there is this stacktrace
> on the console:
>
> java.lang.IllegalStateException: Response is no longer buffering!
>         at
>
> org.apache.wicket.protocol.http.HeaderBufferingWebResponse.reset(HeaderBuffe
> ringWebResponse.java:205)
>         at
>
> org.apache.wicket.request.flow.ResetResponseException$ResponseResettingDecor
> ator.respond(ResetResponseException.java:87)
>         at
>
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(Request
> Cycle.java:861)
>         at
>
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.ja
> va:64)
>         at
>
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.ja
> va:93)
>         at
> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.jav
> a:218)
>         at
>
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(Request
> Cycle.java:289)
>         at
>
> org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilte
> r.java:259)
>         at
>
> org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.jav
> a:201)
>         at
>
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
>         at
>
> com.cantaa.emb.ofsi.frontend.common.OFSIWebFilter.doFilter(OFSIWebFilter.jav
> a:28)
>
>
> This again leads to Wicket trying to deliver the ErrorPage which is not
> wanted.
> So my question is: what do we do wrong? I guess I should not throw an
> AbortException here, but what do I do instead to get a 404 to the browser?
>
> Thank you in advance for any help.
>
>
> -- Cheers, Hans
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to