Reply To: Problem with ConversationScoped / cid parameter

Splash Forums Rewrite Users Problem with ConversationScoped / cid parameter Reply To: Problem with ConversationScoped / cid parameter

#25848

yesar
Participant

After some work on my application I found a new “problem” with conversation.

Normally you have an exception handling for your NonexistentConversationException, something like


<error-page>
	<exception-type>org.jboss.weld.context.NonexistentConversationException</exception-type>
	<location>/errors/noconversation.xhtml?nocid=true</location>
</error-page>

But this exception will get caught in RewriteFilter


try {
	rewrite(event);
}
catch (ServletException e) {
	throw e;
}
catch (Exception e) { // <-- here
	throw new ServletException("Error during Rewrite processing. Please inspect stack trace for root cause.", e);
}

and wrapped in a ServletException. The result is that my exception handling config will not work and instead of my error page, I get the server error page with stack trace…

My workaround is to have a filter configured before rewrite filter (in web.xml), with following code:


public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
	try {
		chain.doFilter(request, response);
	} catch (ServletException se) {
		Throwable t = ExceptionUtils.getRootCause(se); // ExceptionUtils from apache commons
		if (t instanceof NonexistentConversationException) {
			throw (NonexistentConversationException) t;
		}
		throw se;
	}
}

Maybe you can adjust your code to pass the exception?
Also if you have any ideas to better deal with this I’m up for suggestions.

  • This reply was modified 7 years, 11 months ago by  yesar.