Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
MICHAIL MOUDATSOS
Disable verbose error messages
April 2, 2012 5:34 AM
Answer

MICHAIL MOUDATSOS

Rank: Regular Member

Posts: 110

Join Date: October 4, 2011

Recent Posts

Hello all

I ll try to be brief. A client of ours requires that all kind of error messages returned by the server to the client browser to be non verbose. I have partially tackled that by setting
1    <error-page>
2        <error-code>500</error-code>
3        <location>somehting here</location>
4    </error-page>
5    <error-page>
6        <error-code>404</error-code>
7        <location>somehting here</location>
8    </error-page>
in liferay-portal-6.0.6\tomcat-6.0.29\conf\web.xml
However our client still produced some error screens such as the ones attached when tampering with post requests of an authenticated user. The requests relate to a custom portlet we have deployed.

so
1)Any ideas of how to supress such errors
2)Any ideas how to supress any error message in general

Thank you all in advance!
Attachments: error1.bmp (2,940.5k), error2.bmp (919.7k)
David H Nebinger
RE: Disable verbose error messages
April 2, 2012 5:43 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7238

Join Date: September 1, 2006

Recent Posts

You're using JSF, so you'll want to check this out: http://www.softwareengineeringsolutions.com/thoughts/frameworks/JSF.Techniques-Error.Handling.htm
Thomas Buckley
RE: Disable verbose error messages
April 23, 2012 12:24 AM
Answer

Thomas Buckley

Rank: New Member

Posts: 2

Join Date: April 23, 2012

Recent Posts

Hi Michail

I looking for the exact same solution, but have not been able to find anything online on how to supress verbose error messages.
JSF returns errors such as "java.lang.NumberFormatException: For input string: "2012dsafsf"" when tampering with posts.

Did you find a solution to this?

I currently have a small hack (Create a phase listener, search for any messages in current context and remove them if they contain the word "java"). Not good but best I've come up with so far!

Thanks
David H Nebinger
RE: Disable verbose error messages
April 23, 2012 5:41 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7238

Join Date: September 1, 2006

Recent Posts

Did you try any of the things in the link I provided? I've used this to mask all kinds of details from the JSF output...
Thomas Buckley
RE: Disable verbose error messages
April 23, 2012 6:05 AM
Answer

Thomas Buckley

Rank: New Member

Posts: 2

Join Date: April 23, 2012

Recent Posts

Hi David

Yes I've tried all sorts of things including adding errors mapping into web.xml, creating custom converters/validators.
None have worked.

What I need to do is intercept the Exception and remove it from the current faces instance if it is of a certain type of exception (And redirect the user).

I believe this is happening due to the component values not been converted to the appropriate objects at the 'Apply Request Values' phase (Due to their values been tampered with).

I want to send users to a generic error page when these type of errors occur.

Thomas
David H Nebinger
RE: Disable verbose error messages
April 23, 2012 6:18 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7238

Join Date: September 1, 2006

Recent Posts

The portlet 2.0 spec includes a 'portlet filter' mechanism similar to a servlet filter.

I've used this in the past as kind of a 'last resort' method to catch exceptions thrown in the underlying code. The problem for JSF is often that it can swallow the exceptions.

I guess you could try this in order to massage the results.
Neil Griffin
RE: Disable verbose error messages
April 23, 2012 8:21 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2179

Join Date: July 26, 2005

Recent Posts

[moved to Liferay Faces forum category]

Are you using PortletFaces Bridge or Liferay Faces Bridge? Liferay Faces Bridge has a new class named ExceptionHandlerAjaxImpl that tries to prevent Mojarra from swallowing exceptions. It also serves as an example of how to create a custom Ajax exception handler. It should be registered automatically if you have the liferay-faces-bridge-impl JAR in your portlet's WEB-INF/lib folder.

However I think the error message you showed in error2.bmp is one that is handled by the jsf.js JavaScript library. To see what I mean, search for "XML Parsing Error" in the jsf.js source code.

This error is probably the result of a malformedXML JavaScript parsing error. In order to catch this on the server side, I *think* you would have to develop your own PartialResponseWriter wrapper/decorator that checks for well-formedness. I've never tried something like that so it's just a best guess.