[jboss-user] [JBoss Messaging] - JBoss closing JMS connection automatically

bwarren do-not-reply at jboss.com
Wed Apr 8 19:10:09 EDT 2009


I'm creating a connection to a topic like this:


  | public class FOSMessageListener implements MessageListener {
  | 
  |   private ConnectionFactory connectionFactory;
  |   private javax.jms.Connection topicConnection;
  |   private Session session;
  |   private MessageConsumer consumer;
  | 
  |   public FOSMessageListener() {
  |     try {
  |       Context ctx = new InitialContext();
  |       connectionFactory = (ConnectionFactory)ctx.lookup("java:activemq/TopicConnectionFactory");
  |       log.info("got topic connection factory: " + connectionFactory);
  |       Topic topic = (Topic)ctx.lookup("activemq/topic/FOS");
  |       log.info("got topic: " + topic);
  |       topicConnection = connectionFactory.createConnection();
  |       log.info("got topic connection: " + topicConnection);
  |       session = topicConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  |       log.info("got session: " + session);
  |       consumer = session.createConsumer(topic);
  |       log.info("got consumer: " + consumer);
  |       consumer.setMessageListener(this);
  |       log.info("topic listener registered");
  |       //Message message = consumer.receive();
  |       //log.info("message received: " + message);
  |     }
  |     catch(Exception e) {
  |       log.error("JMS Exception", e);
  |     }
  |   }
  | 
  |   public void onMessage(Message message) {
  |     log.info("message received: " + message);
  |   }
  | }
  | 

JBoss is closing the connection automatically right after the connection is created:


  | 15:48:58,863 INFO  [FOSMessageListener] got topic connection factory: org.apache.activemq.ra.ActiveMQConnectionFactory at 1b2fcac
  | 15:48:58,863 INFO  [FOSMessageListener] got topic: topic://topic.FOS
  | 15:48:58,863 INFO  [FOSMessageListener] got topic connection: org.apache.activemq.ra.ManagedConnectionProxy at 14d711
  | 15:48:58,863 INFO  [FOSMessageListener] got session: ManagedSessionProxy { ActiveMQSession {id=ID:76360RWAUIT-4475-1239227462795-2:24:152,started=false} }
  | 15:48:58,863 INFO  [FOSMessageListener] got consumer: ActiveMQMessageConsumer { value=ID:76360RWAUIT-4475-1239227462795-2:24:152:1, started=false }
  | 15:48:58,863 INFO  [FOSMessageListener] topic listener registered
  | 15:48:59,628 INFO  [CachedConnectionManager] Closing a connection for you.  Please close them yourself: org.apache.activemq.ra.ManagedConnectionProxy at 14d711
  | java.lang.Throwable: STACKTRACE
  |         at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:278)
  |         at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:524)
  |         at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
  |         at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:94)
  |         at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:67)
  |         at com.usairways.cbro.rtd.view.FOSMessageListener.<init>(FOSMessageListener.java:51)
  |         at com.usairways.cbro.rtd.view.RtdBackingBean.<init>(RtdBackingBean.java:79)
  |         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  |         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  |         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  |         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
  |         at java.lang.Class.newInstance0(Class.java:350)
  |         at java.lang.Class.newInstance(Class.java:303)
  |         at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186)
  |         at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106)
  |         at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368)
  |         at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:222)
  |         at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86)
  |         at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
  |         at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
  |         at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
  |         at org.apache.el.parser.AstValue.getValue(AstValue.java:107)
  |         at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
  |         at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
  |         at javax.faces.component.UIOutput.getValue(UIOutput.java:184)
  |         at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.getCurrentSelectedValues(MenuRenderer.java:594)
  |         at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.renderOptions(MenuRenderer.java:469)
  |         at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.renderSelect(MenuRenderer.java:412)
  |         at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:119)
  |         at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
  |         at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:367)
  |         at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:208)
  |         at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:517)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
  |         at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
  |         at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:282)
  |         at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153)
  |         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
  |         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
  |         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
  |         at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:17)
  |         at com.icesoft.faces.context.View$2$1.respond(View.java:47)
  |         at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:197)
  |         at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
  |         at com.icesoft.faces.context.View$2.serve(View.java:72)
  |         at com.icesoft.faces.context.View.servePage(View.java:133)
  |         at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:52)
  |         at com.icesoft.faces.webapp.http.common.ServerProxy.service(ServerProxy.java:11)
  |         at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet$4.service(MainSessionBoundServlet.java:114)
  |         at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
  |         at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160)
  |         at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:42)
  |         at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
  |         at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
  |         at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:62)
  |         at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
  |         at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:153)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  |         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
  |         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)
  |         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
  |         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
  |         at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696)
  |         at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667)
  |         at org.apache.jsp.index_jsp._jspService(index_jsp.java:59)
  |         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  |         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
  |         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
  |         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  |         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  |         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
  |         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  |         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
  |         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
  |         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
  |         at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
  |         at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
  |         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  |         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  |         at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
  |         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  |         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
  |         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
  |         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
  |         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  |         at java.lang.Thread.run(Thread.java:595)
  | 

If I comment out setMessageListener() and instead do consumer.receive(), I get a message just fine, then JBoss closes the connection.

Why would my connection be closed right after opening it?  It is not going out of scope or anything.

Environment:
JBoss 5.0.1.GA
ActiveMQ 5.2.0

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4224511#4224511

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4224511



More information about the jboss-user mailing list