0 Replies Latest reply on Jul 8, 2011 2:08 AM by Nagendra Singh

    Connection Close Problem

    Nagendra Singh Newbie

      Hi

       

      I have migrated my code from weblogic to jboss. We have been using ejb 2.0 and ibm mq in our application.

      On Jboss 5.1 we are getting following error:

       

      javax.jms.IllegalStateException: MQJCA1019:Connection closed.

            at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:122)

            at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:80)

            at com.ibm.mq.connector.outbound.ConnectionWrapper.assertOpen(ConnectionWrapper.java:296)

            at com.ibm.mq.connector.outbound.QueueConnectionWrapper.createQueueSession(QueueConnectionWrapper.java:69)

        at

       

      Following are our code sample

       

      Session Bean class "PRV_Service_SurveillanceCollecteBean":


      public abstract class PRV_Service_SurveillanceCollecteBean extends TimerTask implements

              javax.ejb.SessionBean {

       

           public void ejbCreate() throws NSITechnicalException, CreateException {

             

              //logger = Logger.getLogger(this.getClass());

              logger.debug("PRV_Surv_Bean EjbCreated");

             

              if (logger.isDebugEnabled()) logger.debug("PRV_Service_SurveillanceCollecteBean : ejbCreate : DEBUT");

             

              try {

       

                     ctx = new InitialContext();

                  QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup(Constantes.JMS_XA_CONNECTIONFACTORY);

                  qConnection = qcf.createQueueConnection();

       

                }

       

               public void ejbRemove() throws EJBException {

                   if ( logger.isDebugEnabled() ) logger.debug( "PRV_Service_SurveillanceCollecteBean : ejbRemove : DEBUT" );    

            

             

                   try {

                       if (qConnection!=null)

                           qConnection.close();

                   } catch (JMSException e) {

                       logger.error(e);

                   }

       

                   if ( logger.isDebugEnabled() ) logger.debug( "PRV_Service_SurveillanceCollecteBean : ejbRemove : FIN" );

               }  

        

               public void ejbActivate() throws EJBException {

             

               }

       

                public boolean testDisponibiliteCollectes() {

             

                   if (logger.isDebugEnabled())

                       logger.debug("PRV_Service_SurveillanceCollecteBean : testDisponibiliteCollectes : DEBUT ");

                   QueueSender queueSender = null;       

                   QueueSession l_qSession = null;

                   try {          

                 

                       l_qSession = qConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);

                 

                 

                       ParameterListeVO listeNomsQueue;

                 

                      listeNomsQueue = ejbParametres.getParametersBeginningWith(MODULE_BPAI, COLLECTE_FILE_JNDINAME + "_");

                      if (listeNomsQueue == null)

                          throw new Exception("listeNomsQueue récupéré dans JNDI est null");

                 

                 

                  Iterator iterator = listeNomsQueue.getCollection().iterator();

                  while (iterator.hasNext()) {

                     

                      StringParameterVO nomFileCourante = (StringParameterVO) iterator.next();

                     

                      if ( logger.isDebugEnabled() ) logger.debug( "testDisponibiliteCollectes : Nom JNDI d'une des files JMS à destination des Collectes : " + nomFileCourante.getValue() );

                                     

                     

                      Queue queue = (Queue) ctx.lookup( nomFileCourante.getValue() );

                      queueSender = l_qSession.createSender(queue);

                      queueSender.send(l_qSession.createTextMessage(getMessageText()));

                      queueSender.close();

                  }

                  l_qSession.close();          

                 

                  return true;

             

              } catch (Exception e) {           

                  logger.warn("PRV_Service_SurveillanceCollecteBean : testDisponibiliteCollectes : " +

                          "Les collectes ne sont toujours pas disponibles", e);           

                  return false;

                 

              } finally {           

                  sessionContext.setRollbackOnly();          

                  if (logger.isDebugEnabled()) logger.debug("PRV_Service_SurveillanceCollecteBean : testDisponibiliteCollectes : FIN ");

              }

             

          }

       

      The method "testDisponibiliteCollectes" in above session bean is called form some other class file. But we get "Error: connection closed" which we have already created and opened in ejbCreate method of session bean.

       

      This problem does not occur if we create connection in "testDisponibiliteCollectes" method instead of ejbCreate.

       

      Also this problem does not occur in weblogic.

       

       

      Please can somebody suggest what can be the issue.