Alexander Osterwald created AMQ-6791:
----------------------------------------

             Summary: NullPointerException at 
org.apache.activemq.web.SessionPool.getConnection(SessionPool.java:53) hidding 
real cause (JMSException)
                 Key: AMQ-6791
                 URL: https://issues.apache.org/jira/browse/AMQ-6791
             Project: ActiveMQ
          Issue Type: Bug
          Components: webconsole
    Affects Versions: 5.14.0
            Reporter: Alexander Osterwald
            Priority: Trivial


The method {{getConnection}} in {{org.apache.activemq.web.SessionPool}} 
swallows instances of {{JMSException}} in the catch block if line 48 
{{getConnectionFactory().createConnection()}} doesn't return a connection 
object. 

This is the case if  the transport connector for open wire isn't bound to 
{{0.0.0.0}} or at least to {{localhost}} and a client tries to browse a queue 
via ActiveMq webconsole. E.g. if activemq.xml contains the following transport 
connector

{code:xml}
<transportConnectors>
         <transportConnector name="openwire" 
uri="tcp://some_host_name:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            
        </transportConnectors>
{code}
 and a client requests the resource 
{{http://some_host_name/activemqweb/browse.jsp?JMSDestination=some_queue}} the 
error {{Exception occurred while processing this request, check the log for 
more information!}} is displayed in the browser. In this case the log contains 
the following stacktrace:

{code:java}
2017-08-09 06:30:18,198 | WARN  | tp1746037789-343 | ServletHandler             
      | 276 - org.eclipse.jetty.util - 9.2.14.v20151106 | 
org.apache.jasper.JasperException: An exception occurred processing JSP page 
/browse.jsp at line 19

16: --%>
17: <html>
18: <head>
19: <c:set var="pageTitle" value="Browse 
${requestContext.queueBrowser.JMSDestination}"/>
20: 
21: <%@include file="decorators/head.jsp" %>
22: </head>


Stacktrace:
        at 
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:576)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:468)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)[100:javax.servlet-api:3.1.0]
        at 
org.ops4j.pax.web.jsp.JspServletWrapper$2.call(JspServletWrapper.java:155)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.ops4j.pax.web.jsp.JspServletWrapper$2.call(JspServletWrapper.java:151)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.ops4j.pax.swissbox.core.ContextClassLoaderUtils.doWithClassLoader(ContextClassLoaderUtils.java:60)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.ops4j.pax.web.jsp.JspServletWrapper.service(JspServletWrapper.java:150)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[274:org.eclipse.jetty.servlet:9.2.14.v20151106]
        at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)[274:org.eclipse.jetty.servlet:9.2.14.v20151106]
        at 
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)[274:org.eclipse.jetty.servlet:9.2.14.v20151106]
        at 
org.apache.activemq.web.SessionFilter.doFilter(SessionFilter.java:45)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)[274:org.eclipse.jetty.servlet:9.2.14.v20151106]
        at 
org.apache.activemq.web.filter.ApplicationContextFilter.doFilter(ApplicationContextFilter.java:102)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)[274:org.eclipse.jetty.servlet:9.2.14.v20151106]
        at 
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)[274:org.eclipse.jetty.servlet:9.2.14.v20151106]
        at 
org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[317:org.ops4j.pax.web.pax-web-jetty:4.2.4]
        at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[272:org.eclipse.jetty.security:9.2.14.v20151106]
        at 
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:271)[317:org.ops4j.pax.web.pax-web-jetty:4.2.4]
        at 
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[274:org.eclipse.jetty.servlet:9.2.14.v20151106]
        at 
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[317:org.ops4j.pax.web.pax-web-jetty:4.2.4]
        at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.eclipse.jetty.server.Server.handle(Server.java:499)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[273:org.eclipse.jetty.server:9.2.14.v20151106]
        at 
org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)[265:org.eclipse.jetty.io:9.2.14.v20151106]
        at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[276:org.eclipse.jetty.util:9.2.14.v20151106]
        at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[276:org.eclipse.jetty.util:9.2.14.v20151106]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_102]
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'queueBrowser' defined in ServletContext resource 
[/WEB-INF/webconsole-query.xml]: Bean instantiation via constructor failed; 
nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [org.apache.activemq.web.QueueBrowseQuery]: Constructor 
threw exception; nested exception is java.lang.NullPointerException
        at 
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:275)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1137)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1040)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:342)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:44)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:963)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.apache.activemq.web.filter.ApplicationContextFilter$2.get(ApplicationContextFilter.java:178)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
javax.el.MapELResolver.getValue(MapELResolver.java:65)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.el.parser.AstValue.getValue(AstValue.java:167)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.el.parser.AstDynamicExpression.getValue(AstDynamicExpression.java:43)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:49)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:115)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
org.apache.jsp.browse_jsp._jspx_meth_c_005fset_005f0(browse_jsp.java:203)[file:/opt/kisters/energy-offer-handling/karaf/data/pax-web-jsp/activemqweb/:]
        at 
org.apache.jsp.browse_jsp._jspService(browse_jsp.java:109)[file:/opt/kisters/energy-offer-handling/karaf/data/pax-web-jsp/activemqweb/:]
        at 
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)[100:javax.servlet-api:3.1.0]
        at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:431)[318:org.ops4j.pax.web.pax-web-jsp:4.2.4]
        ... 36 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to 
instantiate [org.apache.activemq.web.QueueBrowseQuery]: Constructor threw 
exception; nested exception is java.lang.NullPointerException
        at 
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:267)[109:org.apache.activemq.activemq-web-console:5.14.0]
        ... 58 more
Caused by: java.lang.NullPointerException
        at 
org.apache.activemq.web.SessionPool.getConnection(SessionPool.java:53)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.apache.activemq.web.SessionPool.createSession(SessionPool.java:114)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.apache.activemq.web.SessionPool.borrowSession(SessionPool.java:93)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at 
org.apache.activemq.web.QueueBrowseQuery.<init>(QueueBrowseQuery.java:40)[109:org.apache.activemq.activemq-web-console:5.14.0]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
Method)[:1.8.0_102]
        at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_102]
        at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_102]
        at 
java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_102]
        at 
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)[109:org.apache.activemq.activemq-web-console:5.14.0]
        ... 60 more
{code}

The swallowed exception contains the following message which would be more 
helpful :)
{code:java}
Could not connect to broker URL: tcp://localhost:61616. Reason: 
java.net.ConnectException: Connection refused
{code}




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to