You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Hans Lesmeister 2 <ha...@lessy-software.de> on 2013/08/16 11:45:41 UTC
Mounted Dynamic Resource: IllegalStateException
Hi all,
To deliver resources (mainly images) dynamically, we have created a custom
ResourceReference and mounted that to a path:
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:
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.
-----
--
Regards,
Hans
http://cantaa.de
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Mounted-Dynamic-Resource-IllegalStateException-tp4660927.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
AW: Mounted Dynamic Resource: IllegalStateException
Posted by Hans Lesmeister <ha...@lessy-software.de>.
Sorry, I had attached the WAR-file to the ticket.
Now the ZIP-file is attached to the ticket.
-----Ursprüngliche Nachricht-----
Von: Hans Lesmeister 2 [mailto:hans.lesmeister@lessy-software.de]
Gesendet: Freitag, 16. August 2013 14:07
An: users@wicket.apache.org
Betreff: Re: Mounted Dynamic Resource: IllegalStateException
Hi Martin,
Martin Grigorov-4 wrote
> Please create a ticket with a quickstart and we will take a look.
> Thanks!
Quickstart attached
https://issues.apache.org/jira/browse/WICKET-5318
Thanks a lot
-----
--
Regards,
Hans
http://cantaa.de
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Mounted-Dynamic-Resource-IllegalS
tateException-tp4660927p4660930.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Mounted Dynamic Resource: IllegalStateException
Posted by Hans Lesmeister 2 <ha...@lessy-software.de>.
Hi Martin,
Martin Grigorov-4 wrote
> Please create a ticket with a quickstart and we will take a look.
> Thanks!
Quickstart attached
https://issues.apache.org/jira/browse/WICKET-5318
Thanks a lot
-----
--
Regards,
Hans
http://cantaa.de
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Mounted-Dynamic-Resource-IllegalStateException-tp4660927p4660930.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Mounted Dynamic Resource: IllegalStateException
Posted by Martin Grigorov <mg...@apache.org>.
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 <
hans.lesmeister@lessy-software.de> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
AW: Mounted Dynamic Resource: IllegalStateException
Posted by Hans Lesmeister <ha...@lessy-software.de>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org