[jboss-user] [JBoss Messaging] - Failed to get a server session

santhosh pulichinthala do-not-reply at jboss.com
Sat Jul 17 04:57:59 EDT 2010


santhosh pulichinthala [http://community.jboss.org/people/santhoshreddy747] replied to the discussion

"Failed to get a server session"

To view the discussion, visit: http://community.jboss.org/message/553138#553138

--------------------------------------------------------------
HI,
 Can you please send me your MDB code to fix this problem.Im also having same issues.Im also recieving the message as message listener.
Im attaching my MDB code please let me know if i did anything wrong.
Thanks
santhosh

mdb main code:
// Source File Name:   EskomMDB.java
//@author santhosh pulichinthala
package za.eskom.jms.ejb;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJBException;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.Message;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
// Referenced classes of package za.eskom.jms.ejb:
//            EscapeChars, GTXSOAPCalling , GetSoapXmlByMsgType , PersistentSoapTarget
public class GtxEskomFourthInstanceMDB implements MessageDrivenBean, MessageListener {
 private MessageDrivenContext mdcontext;
 String soapTargetValue = null;
 private boolean instantiated;
 String messageType = "";   
 InitialContext initialContext = null;
 Thread currentThread = null;
 public GtxEskomFourthInstanceMDB() {
  mdcontext = null;
  instantiated = getVariables();
 }
 public void setMessageDrivenContext(MessageDrivenContext mdc)
   throws EJBException {
  mdcontext = mdc;
 }
 public void ejbCreate() {
 }
 public void ejbRemove() {
 }
 private boolean getVariables() {
  // TODO Auto-generated method stub
  String variableName = "";
  try {
   // createQueueConnetion();
   initialContext = new InitialContext();
   Context context = (Context) initialContext.lookup("java:comp/env");
   variableName = "SoapTargetValue";
   soapTargetValue = (String) context.lookup(variableName);
   variableName = "MessageType";
   messageType = (String) context.lookup(variableName);
   return true;
  } catch (NamingException excepton) {
   logger.log(Level.SEVERE, "Missing environment variable ("
     + variableName + ") from ejb-jar.xml .");
   return false;
  }
 }
 public void onMessage(Message inMessage) {
  TextMessage msg = null;
  String xmlString = "";
  String xmlToSend = "";
  Queue subscribedQueue;
  try {
       
   subscribedQueue = (Queue) inMessage.getJMSDestination();
       
   logger.log(Level.INFO, "Received JMS message ("
     + inMessage.getJMSMessageID() + ") from Queue ("
     + subscribedQueue.getQueueName() + ").");     
   if (inMessage instanceof TextMessage) {
    msg = (TextMessage) inMessage;
    xmlToSend = msg.getText().toString();
    if (instantiated) {
     logger.log(Level.INFO,
       "MESSAGE BEAN: Got the message Type :  "
         + messageType + " and SoapTargetValue :  "
         + soapTargetValue);
    } else {
     logger.log(Level.SEVERE,
       "MESSAGE BEAN: Failed read values from ejb-jar.xml for xml Message"
         + msg.getText().toString());
     mdcontext.setRollbackOnly();
    }
    xmlString = GetSoapXmlByMsgType.getMessageType(messageType,
      xmlToSend);
    logger.log(Level.INFO,
      "MESSAGE BEAN: Calling Gtx Soap process :");
    GTXSOAPCalling
      .callingGtxSoapProcess(soapTargetValue, xmlString);
   }
  } catch (Throwable e) {
   // TODO Auto-generated catch block
   try {
    mdcontext.setRollbackOnly();
   } catch (Exception f) {
    logger.log(Level.SEVERE,
      "Failure when trying to rollback transaction");
   }
   logger.log(Level.SEVERE,
     "Failed to submit JMS message  with an exception - "
       + e.getMessage());
  }
 }
 private static final long serialVersionUID = 1L;
 private static Logger logger = Logger.getLogger("GtxEskomMessageBean");
}

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/553138#553138]

Start a new discussion in JBoss Messaging at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100717/b9742fa4/attachment.html 


More information about the jboss-user mailing list