Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B50689D4B for ; Thu, 12 Apr 2012 13:25:46 +0000 (UTC) Received: (qmail 59388 invoked by uid 500); 12 Apr 2012 13:25:43 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 59184 invoked by uid 500); 12 Apr 2012 13:25:43 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 59163 invoked by uid 99); 12 Apr 2012 13:25:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 13:25:43 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of knst.kolinko@gmail.com designates 209.85.160.173 as permitted sender) Received: from [209.85.160.173] (HELO mail-gy0-f173.google.com) (209.85.160.173) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 13:25:37 +0000 Received: by ghrr14 with SMTP id r14so1276203ghr.18 for ; Thu, 12 Apr 2012 06:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=mGSPX2b8Zhpwoi+X6OqgL/pJFWbdpn8eB9BKHjswiTA=; b=mAgyKJ2qBXHY97QbAY1WyLR2jiU7HeZVoCRXCBWCmWI21DWV7m7X0Clbb5qLoeETxN fjT/6DmtpzTtaSvLZF/PvtLdDrk542EF1UMYWlUUq8bFqfN3mfkodf+rL+PFE/4W7AsB 6i0Jzi30pSHT0hdYO5mo1UPuKl++qJx8h6jkEzwHYLDyRq8fQo5p2UWyJSjUbE7Z9nPn +LnMOyYCi0GfJCNvJt/on4jZZyjxWiqlqBvY8aKYTT16YQiHPv5vR8+8YMLXfWrlZK9+ xCToKFHhm6LqahXzqE9dsopk5KqZAG3qNfvYfzGdU1sfnJ1pM7oIQHxjYF1RpV+ZoR6D unXg== MIME-Version: 1.0 Received: by 10.236.115.200 with SMTP id e48mr420228yhh.14.1334237116270; Thu, 12 Apr 2012 06:25:16 -0700 (PDT) Received: by 10.146.204.18 with HTTP; Thu, 12 Apr 2012 06:25:16 -0700 (PDT) In-Reply-To: <6368FCCCD803D64BB0931D7F5F0A3DD50227830AB1@DEMCHP99E84MSX.ww902.siemens.net> References: <6368FCCCD803D64BB0931D7F5F0A3DD50227830AB1@DEMCHP99E84MSX.ww902.siemens.net> Date: Thu, 12 Apr 2012 17:25:16 +0400 Message-ID: Subject: Re: StandardHostValve kills custom error message From: Konstantin Kolinko To: Tomcat Users List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2012/4/12 Osipov, Michael : > Hi folks, > > I am sending a custom error message in my authenticator but it gets remov= ed by the StandardHostValve. > This is what I do in my authenticator: > > catch (PrivilegedActionException e) { > =A0 logger.error("Unable to login as the service principal", e.getExcepti= on()); > > =A0 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, > =A0 =A0 "Unable to login as the service principal"); > =A0 request.setAttribute(Globals.EXCEPTION_ATTR, e); What happens if you switch the order of the above two lines? IMHO it is odd to do something after sendError(), sendRedirect() or RequestDispatcher.forward(). > =A0 return false; > } > > The message is not diplayed because in line 282 to 286 the message is kil= led by: > else { > =A0 =A0 =A0 =A0 =A0 =A0// A custom error-page has not been defined for th= e exception > =A0 =A0 =A0 =A0 =A0 =A0// that was thrown during request processing. Chec= k if an > =A0 =A0 =A0 =A0 =A0 =A0// error-page for error code 500 was specified and= if so, > =A0 =A0 =A0 =A0 =A0 =A0// send that page back as the response. > =A0 =A0 =A0 =A0 =A0 =A0response.setStatus(HttpServletResponse.SC_INTERNAL= _SERVER_ERROR); > =A0 =A0 =A0 =A0 =A0 =A0// The response is an error > =A0 =A0 =A0 =A0 =A0 =A0response.setError(); > > =A0 =A0 =A0 =A0 =A0 =A0status(request, response); > =A0 =A0 =A0 =A0} > > It seems like this valve does not care if it handles an uncaught exceptio= n or a deliberate exception. > Can this be fixed without patching the valve? > > I guess not. I would file a ticket about that: A mere response#isError ca= ll would suffice to wrap that behavior and pass the response as is. > My understanding is that it is responsibility of the Container to provide the value for the request attribute "javax.servlet.error.exception" You cannot set it. See 10.9.1 in Servlet 3.0 spec. Can't you just throw new ServletException(PrivilegedActionException); ? Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org