You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Hans Lesmeister (JIRA)" <ji...@apache.org> on 2013/08/16 14:51:48 UTC
[jira] [Commented] (WICKET-5318) Mounted Dynamic Resource:
IllegalStateException
[ https://issues.apache.org/jira/browse/WICKET-5318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13742174#comment-13742174 ]
Hans Lesmeister commented on WICKET-5318:
-----------------------------------------
Attached ZIP-file (instead of WAR-file)
> Mounted Dynamic Resource: IllegalStateException
> -----------------------------------------------
>
> Key: WICKET-5318
> URL: https://issues.apache.org/jira/browse/WICKET-5318
> Project: Wicket
> Issue Type: Task
> Components: wicket
> Affects Versions: 6.8.0
> Environment: Java 1.6, Windows 7
> Reporter: Hans Lesmeister
> Attachments: QuickStartWicket6.zip
>
>
> Copied from:
> http://apache-wicket.1842946.n4.nabble.com/Mounted-Dynamic-Resource-IllegalStateException-td4660927.html
> 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(HeaderBufferingWebResponse.java:205)
> at org.apache.wicket.request.flow.ResetResponseException$ResponseResettingDecorator.respond(ResetResponseException.java:87)
> at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
> at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
> at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:93)
> at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
> at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
> at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
> at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
> at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
> at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
> at com.cantaa.emb.ofsi.frontend.common.OFSIWebFilter.doFilter(OFSIWebFilter.java: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?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira