|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Exception - init MQ API 7.5 with ASP.NET on WinSvr2003R2SP2 |
« View previous topic :: View next topic » |
Author |
Message
|
jasio |
Posted: Thu Feb 28, 2013 7:42 am Post subject: Exception - init MQ API 7.5 with ASP.NET on WinSvr2003R2SP2 |
|
|
Newbie
Joined: 28 Feb 2013 Posts: 4
|
Hello!
I have a problem while running a simple MQ test on a WinSvr2003R2SP2.
MQ API is called from an ASP.NET page.
On a local computer (WinXP) it runs fine.
On the server it encounters an error.
Quote: |
Failed to load mqe.dll from folder ...\IBM\WebSphere MQ\bin\
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Failed to load mqe.dll from folder ...\IBM\WebSphere MQ\bin\
Source Error:
Line 151: // create connection
Line 152: log("Connecting to queue manager.. ");
Line 153: queueManager = new MQQueueManager(mqQueueManagerName, properties);
Line 154: log("done");
Line 155:
Source File: ...\mqwebpages1\App_Code\MQMsgHandler.cs Line: 153
Stack Trace:
[Exception: Failed to load mqe.dll from folder ...\IBM\WebSphere MQ\bin\]
IBM.WMQ.Nmqi.NativeManager.InitializeNativeApis(String mode) +850
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
IBM.WMQ.MQCommonServices..ctor() +391
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230
System.Activator.CreateInstance(Type type, Boolean nonPublic) +67
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +7653583
System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +28
IBM.WMQ.CommonServices.CreateCommonServices() +685
IBM.WMQ.CommonServices.TraceEnabled() +36
IBM.WMQ.MQBase..ctor() +45
IBM.WMQ.Nmqi.NmqiEnvironment..ctor(NmqiPropertyHandler nmqiPropertyHandler) +127
IBM.WMQ.Nmqi.NmqiFactory.GetInstance(NmqiPropertyHandler properties) +180
IBM.WMQ.MQQueueManager..cctor() +29
[TypeInitializationException: The type initializer for 'IBM.WMQ.MQQueueManager' threw an exception.]
IBM.WMQ.MQQueueManager..ctor(String queueManagerName, Hashtable properties) +0
MQMsgHandler.PutMessage() in ...\mqwebpages1\App_Code\MQMsgHandler.cs:153
_Default.CalendarChanged(Object sender, EventArgs e) in ...\mqwebpages1\Default.aspx.cs:50
System.Web.UI.WebControls.Calendar.OnSelectionChanged() +123
System.Web.UI.WebControls.Calendar.SelectRange(DateTime dateFrom, DateTime dateTo) +295
System.Web.UI.WebControls.Calendar.RaisePostBackEvent(String eventArgument) +1012
System.Web.UI.WebControls.Calendar.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3643; ASP.NET Version:2.0.50727.3634 |
MQ Client 7.5 is installed on both (local WinXP and WinSvr2003R2SP2).
Both systems restarted.
The user the IIS application pool runs as is added to mqm group.
It does not matter wheteher I use MQC.TRANSPORT_MQSERIES_CLIENT or MQC.TRANSPORT_MQSERIES_MANAGED connection type (trasport property).
The part of the code (adapted from sample):
Code: |
public string PutMessage()
{
string rslt = "";
try
{
// mq properties
properties = prepareConnectionProperties(connectionType);
// display all details
log("MQ Parameters");
log("1) queueName = " + mqReqQueueName);
log("2) host = " + mqHostName);
log("3) port = " + mqPort);
log("4) channel = " + mqChannelName);
log("5) CCSID = " + mqCharacterSet.ToString());
log("");
// create connection
log("Connecting to queue manager.. ");
queueManager = new MQQueueManager(mqQueueManagerName, properties);
log("done");
// accessing queue
log("Accessing queue " + mqReqQueueName + "... ");
queue = queueManager.AccessQueue(mqReqQueueName, MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING);
log("done");
// creating a message object
mqMessage = new MQMessage();
mqMessage.CharacterSet = mqCharacterSet;
mqMessage.Expiry = 3000;
//mqMessage.MessageType = MQC.MQMT_REQUEST;
mqMessage.Format = MQC.MQFMT_NONE;
MemoryStream ostrm = new MemoryStream();
XmlWriterSettings xmlSettings = new XmlWriterSettings();
xmlSettings.Encoding = encoding;
xmlSettings.Indent = true;
xmlSettings.IndentChars = " ";
XmlWriter tw = XmlWriter.Create(ostrm, new XmlWriterSettings());
req.WriteTo(tw);
tw.Flush();
mqMessage.Write(ostrm.ToArray());
tw.Close();
ostrm.Close();
// putting messages continuously
log("Message... ");
queue.Put(mqMessage);
log("put");
// closing queue
log("Closing queue.. ");
queue.Close();
log("done");
log("msg id: "+BitConverter.ToString(mqMessage.MessageId));
// accessing queue
log("Accessing queue " + mqRspQueueName + "... ");
queue = queueManager.AccessQueue(mqRspQueueName, MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING);
log("done");
MQMessage rsp = new MQMessage();
MQGetMessageOptions rspGMO = new MQGetMessageOptions();
rsp.CorrelationId = mqMessage.MessageId;
rspGMO.MatchOptions = MQC.MQMO_MATCH_CORREL_ID;
//rspGMO.MatchOptions = MQC.MQMO_NONE;
rspGMO.Options = MQC.MQGMO_WAIT;
rspGMO.WaitInterval=1000;
int tries = 10;
bool wait4rsp = true;
while (wait4rsp)
{
try
{
tries--;
queue.Get(rsp, rspGMO);
rslt = rsp.ReadString(10000);
wait4rsp = false;
} catch (MQException mqe) {
log(String.Format("MQException caught: {0}, {1} - {2}", mqe.CompletionCode, mqe.ReasonCode, mqe.Message));
//log("completionCode:" + mqe.CompletionCode);
//log("reasonCode:" + mqe.ReasonCode);
switch (mqe.ReasonCode)
{
case MQC.MQRC_NO_MSG_AVAILABLE:
wait4rsp = true;
break;
case MQC.MQRC_HCONN_ERROR:
case MQC.MQRC_HOBJ_ERROR:
case MQC.MQRC_CONNECTION_QUIESCING:
case MQC.MQRC_CONNECTION_BROKEN:
case MQC.MQRC_CONNECTION_STOPPING:
case MQC.MQRC_Q_MGR_STOPPING:
case MQC.MQRC_Q_MGR_QUIESCING:
case MQC.MQRC_Q_MGR_NOT_ACTIVE:
log("closing...");
wait4rsp = false;
break;
case MQC.MQRC_DATA_LENGTH_ERROR:
log("data length error");
wait4rsp = false;
break;
default:
wait4rsp = false;
break;
}
}
if (tries < 0) {
log("Trial limit exhausted. Giving up.");
wait4rsp = false;
}
}
// closing queue
log("Closing queue.. ");
queue.Close();
log("done");
// disconnecting queue manager
log("Disconnecting queue manager.. ");
queueManager.Disconnect();
log("done");
}
catch (MQException mqe)
{
log("");
log(String.Format("MQException caught: {0} - {1}", mqe.ReasonCode, mqe.Message));
log(mqe.StackTrace);
}
return rslt;
}
|
|
|
Back to top |
|
 |
mqjeff |
Posted: Thu Feb 28, 2013 7:51 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The default installation location for the MQ client is different on XP and 2003 server, if I recall correctly.
The actual installation location is chosen by the person who performs the install, so it may very well not even be in the default location. |
|
Back to top |
|
 |
jasio |
Posted: Thu Feb 28, 2013 7:58 am Post subject: |
|
|
Newbie
Joined: 28 Feb 2013 Posts: 4
|
Of course the locations are different, but...
ASP.NET page knows where are the folders.
What makes the problem is it could not initialize.
I do not have sources of MQ api to detect what realy happens.
Could it be a security problem?
Quote: |
[Exception: Failed to load mqe.dll from folder ...\IBM\WebSphere MQ\bin\]
IBM.WMQ.Nmqi.NativeManager.InitializeNativeApis(String mode) +850 |
mqm group has rights to read and execute files from this folder.
ASPNET is member of mqm group too. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Feb 28, 2013 8:05 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
jasio wrote: |
Of course the locations are different, but...
ASP.NET page knows where are the folders.
What makes the problem is it could not initialize.
I do not have sources of MQ api to detect what realy happens.
Could it be a security problem?
Quote: |
[Exception: Failed to load mqe.dll from folder ...\IBM\WebSphere MQ\bin\]
IBM.WMQ.Nmqi.NativeManager.InitializeNativeApis(String mode) +850 |
mqm group has rights to read and execute files from this folder. |
Right, my question is, is that location correct for the server?
Or not?
it's saying it can't find the things it needs to in that location. So if they're installed somewhere else, that's why. |
|
Back to top |
|
 |
jasio |
Posted: Thu Feb 28, 2013 8:25 am Post subject: |
|
|
Newbie
Joined: 28 Feb 2013 Posts: 4
|
Yes, the location it mentions in the error description is correct.
mqe.dll resides there, with all the other libraries and programs.
Group mqm has rights to read and execute as the installer has set.
Environment variables set (and correct):
MQ_DATA_PATH (I have set it),
MQ_ENV_MODE (I have set it),
MQ_FILE_PATH,
MQ_JAVA_DATA_PATH,
MQ_JAVA_INSTALL_PATH,
MQ_JRE_PATH.
If the Web application pool runs as LocalSystem, everything works fine.
If it runs with reduced rights (LocalService, NetworkService, dedicated account) the problem occurs. |
|
Back to top |
|
 |
jasio |
Posted: Fri Mar 01, 2013 2:09 am Post subject: |
|
|
Newbie
Joined: 28 Feb 2013 Posts: 4
|
EUREKA!!!
Due to server system hardening there were no rights to drive (root folder) where binaries were installed.
So...
I have created a group mqu (for mq users), added my tech. user used in WebAppPool of my ASP.NET application to the group (mqu).
I have granted mqu group "List folder contents" right on the drive (root folder) where binaries reside.
I have granted mqu group "Read and Execute" rights on "Websphere MQ" folder (its child is bin folder).
... restarted IIS ... and it works!!!
Thaks for good will and interest!  |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|