Hi, Wicket catches all runtime exceptions and gives them to all configured IRequestCycleListeners (#onException()). If none of them knows how to process the exception then the exception is given to IExceptionMapper (see Application#newExceptionMapper). The default impl of this mapper is to show the configured IApplicationSettings#getInternalErrorPage().
As a final resort you can provide your own IExceptionMapper that re-throws OAuth2AccessTokenRequiredExcep**tion. On Wed, May 29, 2013 at 2:41 PM, Eusie <ygou....@gmail.com> wrote: > Hi, > > I am using Spring OAuth2ClientContextFilter to handle the OAuth Dance. In > the thread calling stack, OAuth2ClientContextFilter is in the upstream of > WicketFilter (See below the Error Message). > > When an access token is needed, I'd like to throw an > OAuth2AccessTokenRequiredExcep**tion exception in Wicket so as to ask the > upstream OAuth2ClientContextFilter to handle the exception to redirect the > user to be authenticated. > > But the problem is Wicket Page seems not able to throw an exception as > below: > > public HomePage(final PageParameters parameters) throws Exception { > } > > ################### Error Message ################### > > Last cause: OAuth2 access denied. > WicketMessage: Can't instantiate page using constructor 'public > com.mycompany.HomePage(org.**apache.wicket.request.mapper.**parameter.PageParameters) > throws java.lang.Exception' and argument ''. Might be it doesn't exist, may > be it is not visible (public). > > Stacktrace > > Root cause: > > org.springframework.security.**oauth2.client.** > OAuth2AccessTokenRequiredExcep**tion: OAuth2 access denied. > at com.mycompany.HomePage.<init>(**HomePage.java:22) > at java.lang.reflect.Constructor.**newInstance(Constructor.java:** > 513) > at org.apache.wicket.session.**DefaultPageFactory.newPage(** > DefaultPageFactory.java:170) > at org.apache.wicket.session.**DefaultPageFactory.newPage(** > DefaultPageFactory.java:75) > at org.apache.wicket.**DefaultMapperContext.**newPageInstance(** > DefaultMapperContext.java:133) > at org.apache.wicket.core.**request.handler.PageProvider.** > resolvePageInstance(**PageProvider.java:278) > at org.apache.wicket.core.**request.handler.PageProvider.** > getPageInstance(PageProvider.**java:166) > at org.apache.wicket.request.**handler.render.PageRenderer.** > getPage(PageRenderer.java:78) > at org.apache.wicket.request.**handler.render.** > WebPageRenderer.renderPage(**WebPageRenderer.java:94) > at org.apache.wicket.request.**handler.render.** > WebPageRenderer.respond(**WebPageRenderer.java:244) > at org.apache.wicket.core.**request.handler.** > RenderPageRequestHandler.**respond(**RenderPageRequestHandler.java:**165) > at org.apache.wicket.request.**cycle.RequestCycle$** > HandlerExecutor.respond(**RequestCycle.java:830) > at org.apache.wicket.request.**RequestHandlerStack.execute(** > RequestHandlerStack.java:64) > at org.apache.wicket.request.**cycle.RequestCycle.execute(** > RequestCycle.java:253) > at org.apache.wicket.request.**cycle.RequestCycle.** > processRequest(RequestCycle.**java:210) > at org.apache.wicket.request.**cycle.RequestCycle.** > processRequestAndDetach(**RequestCycle.java:281) > at org.apache.wicket.protocol.**http.WicketFilter.** > processRequest(WicketFilter.**java:188) > at org.apache.wicket.protocol.**http.WicketFilter.doFilter(** > WicketFilter.java:245) > at org.apache.catalina.core.**ApplicationFilterChain.** > internalDoFilter(**ApplicationFilterChain.java:**235) > at org.apache.catalina.core.**ApplicationFilterChain.**doFilter(** > ApplicationFilterChain.java:**206) > at org.springframework.security.**web.FilterChainProxy$** > VirtualFilterChain.doFilter(**FilterChainProxy.java:312) > at org.springframework.security.**web.access.intercept.** > FilterSecurityInterceptor.**invoke(**FilterSecurityInterceptor.**java:116) > at org.springframework.security.**web.access.intercept.** > FilterSecurityInterceptor.**doFilter(**FilterSecurityInterceptor.** > java:83) > at org.springframework.security.**web.FilterChainProxy$** > VirtualFilterChain.doFilter(**FilterChainProxy.java:324) > at org.springframework.security.**oauth2.client.filter.** > OAuth2ClientContextFilter.**doFilter(**OAuth2ClientContextFilter.** > java:94) > > ##############################**####################### > > While in Spring MVC, an exception can be thrown like this: > > @RequestMapping("/orcid/info") > public String orcidInfo(Model model, HttpSession session) throws > Exception { > } > > My question is: how can I throw an exception in Wicket, which will be > handled by another upstream filter, say OAuth2ClientContextFilter in this > case. > > Many thanks, > Yuci >