From 02538ed9061b1a57c1a8b0c5accff76465429da0 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Fri, 23 Nov 2012 14:19:24 +0000 Subject: [PATCH] ensure connection/authentication errors with broker facade end up in the log as referenced by our 500 page git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1412899 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/web/filter/ApplicationContextFilter.java | 11 +++++++++-- .../test/java/org/apache/activemq/web/tool/Main.java | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java b/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java index 6b39ba6558..9846d37623 100644 --- a/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java +++ b/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java @@ -33,6 +33,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.activemq.web.BrokerFacade; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.web.bind.ServletRequestDataBinder; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -58,6 +60,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils; * */ public class ApplicationContextFilter implements Filter { + private static final transient Logger LOG = LoggerFactory.getLogger(ApplicationContextFilter.class); private ServletContext servletContext; private String applicationContextName = "applicationContext"; @@ -83,12 +86,16 @@ public class ApplicationContextFilter implements Filter { String path = ((HttpServletRequest)request).getRequestURI(); // handle slave brokers try { - if (((BrokerFacade)requestContextWrapper.get("brokerQuery")).isSlave() - && (!(path.endsWith("css") || path.endsWith("png")) && !path.endsWith(slavePage))) { + if ( !(path.endsWith("css") || path.endsWith("png") || path.endsWith("ico") || path.endsWith(slavePage)) + && ((BrokerFacade)requestContextWrapper.get("brokerQuery")).isSlave()) { ((HttpServletResponse)response).sendRedirect(slavePage); return; } } catch (Exception e) { + LOG.warn(path + ", failed to access BrokerFacade: reason: " + e.getLocalizedMessage()); + if (LOG.isDebugEnabled()) { + LOG.debug(request.toString(), e); + } throw new IOException(e); } request.setAttribute(requestContextName, requestContextWrapper); diff --git a/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java b/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java index 549e3c1fc1..1eb6583290 100644 --- a/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java +++ b/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java @@ -51,6 +51,11 @@ public final class Main { SelectChannelConnector connector = new SelectChannelConnector(); connector.setPort(port); connector.setServer(server); + + //System.setProperty("webconsole.type","properties"); + //System.setProperty("webconsole.jms.url","tcp://localhost:61616"); + //System.setProperty("webconsole.jmx.url","service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root"); + WebAppContext context = new WebAppContext(); context.setResourceBase(WEBAPP_DIR);