Greetings All, This is probably a dumb question, and being this close to Friday will generate short flippant answers, but here goes anyway…
I have a need to communicate via IBM MQSeries to a legacy application. This application has a listener that monitors the queue and posts events in the legacy application based on messages it reads from said queue. I have successfully tested putting messages on the queue from a java class. However when I try to call my MessageManager class from my Action class all I ever get is a NoClassDefFoundError. The MessageManager class imports all the necessary MQ packages, and it also catches all MQ exceptions and throws a “MessageManagerException” instead. I have a test driver that calls this class (independent of my ActionServlet), and I can successfully call it all day long. However, as soon as I try to make the call from my Action subclass I get the NoClassDefFoundError. Why, when I call my MessageManager from my test class, does it work, but when I call it from my Action class it fails? If anyone has any ideas please let me know. The source is posted below. Thanks in advance, Mark N. ============================ ForteMessageManager class ============================ package dhs.vcm.forte.messaging; import com.ibm.mq.*; /* There are three jar files required in the workspace com.ibm.mq.jar com.ibm.mq.iiop.jar com.ibm.mqbind.jar These should all be in the java/lib directory where MQ client is installed. The mqbind.jar file isn't used except for class definitions and was only found in the 5.2 installation of MQ Client. */ //----------------------------------------------------- ForteMessageManager public class ForteMessageManager { //----------------------------------------------------- putMessage public static void putMessage(String msg) throws ForteMessageException { try { System.out.println("ForteMessageManager.putMessage ... about to establish Connection pool") ; ForteMessageConnectionPool messagePool = new ForteMessageConnectionPool(); // open the queue System.out.println("ForteMessageManager.putMessage ... about to open queue") ; MQQueue myQueue = messagePool.getConnection(1); // Define a simple MQSeries message, and put message text System.out.println("ForteMessageManager.putMessage ... about to define message ") ; MQMessage myMessage = new MQMessage(); myMessage.writeUTF(msg); // specify the message options... System.out.println("ForteMessageManager.putMessage ... about to specify message options") ; MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults, use MQPMO_DEFAULT constant // put the message on the queue System.out.println("ForteMessageManager.putMessage ... about to place message on queue") ; myQueue.put(myMessage,pmo); // Close the queue System.out.println("ForteMessageManager.putMessage ... about to close the queue") ; messagePool.releaseConnection(myQueue); } catch (ForteMessageException ex) { } catch (MQException ex) { ForteMessageException newEx = new ForteMessageException(ex.getMessage()); newEx.setCompletionCode(ex.completionCode); newEx.setReasonCode(ex.reasonCode); throw newEx; } catch (java.io.IOException ex) { throw new ForteMessageException(ex.getMessage()); } } //----------------------------------------------------- getMessage public static String getMessage() throws ForteMessageException { String msgText = null; try { ForteMessageConnectionPool messagePool = new ForteMessageConnectionPool(); // open the queue MQQueue myQueue = messagePool.getConnection(1); // Define a MQSeries message buffer to receive the message into.. MQMessage retrievedMessage = new MQMessage(); // Set the get message options.. MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults, use MQGMO_DEFAULT constant // get the message off the queue.. myQueue.get(retrievedMessage, gmo); // set the return value msgText = retrievedMessage.readUTF(); // Close the queue messagePool.releaseConnection(myQueue); } catch (ForteMessageException ex) { } catch (MQException ex) { ForteMessageException newEx = new ForteMessageException(ex.getMessage()); newEx.setCompletionCode(ex.completionCode); newEx.setReasonCode(ex.reasonCode); throw newEx; } catch (java.io.IOException ex) { throw new ForteMessageException(ex.getMessage()); } return msgText; } // end of mqTest //----------------------------------------------------- ForteMessageManager - end } ============================= Action Class sample ============================= package dhs.vcm.vis.action; // -------------------------------------------------------------- Java Includes import java.io.IOException; import java.util.Hashtable; import java.util.Locale; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; // -------------------------------------------------------------- Struts Includes import org.apache.struts.action.ActionForm ; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; import org.apache.struts.util.MessageResources; // -------------------------------------------------------------- DHS Imports import dhs.vcm.forte.messaging.* ; import dhs.vcm.vis.business.* ; import dhs.vcm.vis.entity.* ; import dhs.vcm.vis.form.* ; import dhs.vcm.vis.struts.action.VISAction ; import dhs.vcm.vis.util.* ; public class EnterVisitorActionDisplay extends VISAction { public ActionForward perform( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { writeToLog(" EnterVisitorActionDisplay : perform : entered") ; // Extract attributes we will need Locale locale = getLocale(request); MessageResources messages = getResources(); HttpSession session = request.getSession(); writeToLog(" EnterVisitorActionDisplay : perform : posting message") ; // Call Forte Message Manager passing it the request to display proper window messageToPost = "dhsv022910BeginRegisterVisitor" ; putMessageToQueue(messageToPost) ; writeToLog(" EnterVisitorActionDisplay : perform : leaving now") ; // Forward control to the specified success URI return (mapping.findForward("enterVisitor")); } } ============================ Action superclass ============================ package dhs.vcm.struts.action; // -------------------------------------------------------------- DHS imports import dhs.struts.action.DHSAction ; import dhs.vcm.forte.messaging.ForteMessageException ; import dhs.vcm.forte.messaging.ForteMessageManager ; import dhs.vcm.vis.business.ForteMessageProxy ; public class VCMAction extends dhs.struts.action.DHSAction { public void putMessageToQueue( String messageToPost) { writeToLog(" VCMAction.putMessageToQueue entered... about to post message") ; ForteMessageManager.putMessage(messageToPost) ; } public void getMessageFromQueue(){ try { String myMsg = ForteMessageManager.getMessage(); writeToLog(myMsg); } catch (ForteMessageException ex) { } } } _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>