----- Original Message ----
From: David Avendasora <email@hidden>
To: WebObjects-Dev List <email@hidden>
Sent: Thursday, January 17, 2008 2:48:23 PM
Subject: NPE from executeStoredProcedure()
Hi all,
This is my first time trying to use EOUtilities.executeStoredProcedure and I'm getting a Null Pointer Exception from the following code (see Stack Trace below)
String siteId = "WAREHOUSE";
String batchId;
if (usedInManufacturedBatch() != null) {
batchId = EOUtilities.primaryKeyForObject(ec,usedInManufacturedBatch()).valueForKey("lotCodeId").toString();
} else {
batchId = "";
}
NSMutableDictionary inputArgs = new NSMutableDictionary();
inputArgs.takeValueForKey(batchId, "@BatchID");
inputArgs.takeValueForKey(componentPart().partNumber(),"@ItemNumber");
inputArgs.takeValueForKey(componentQuantity(), "@QTY");
inputArgs.takeValueForKey(siteId, "@SiteID");
inputArgs.takeValueForKey(partUsageType().typeName(),"@Classification");
inputArgs.takeValueForKey(null,"@outIVDocNum");
inputArgs.takeValueForKey(null,"@outErrStatus");
inputArgs.takeValueForKey(null,"@outErrMsg");
log.debug("About to EXEC BM.dbo.ott_spInventoryAdjustment" +
"\n@BatchID = " + inputArgs.valueForKey("@BatchID") +
"\n@ItemNumber = " + inputArgs.valueForKey("@ItemNumber") +
"\n@QTY = " + inputArgs.valueForKey("@QTY") +
"\n@SiteID = " + inputArgs.valueForKey("@SiteID") +
"\n@Classification = " + inputArgs.valueForKey("@Classification")
);
-> NSDictionary outputArgs = EOUtilities.executeStoredProcedureNamed(ec, "[Server].[DBName].[dbo].[sp_Stored_Procedure]", inputArgs);
setPartUsageStatusRelationship(PartUsageStatus.fetchOneSentToInventoryManagement(ec));
setGpIvDocumentNumber((String) outputArgs.valueForKey("@outIVDocNum"));
setGpErrorStatus((Integer) outputArgs.valueForKey("@outErrStatus"));
setGpErrorMessage((String) outputArgs.valueForKey("@outErrMsg"));
It is a MS SQL Server database, and it resides on a different server than the one my application normally uses. I can execute the stored procedure through a normal SQL client with no problem. The output of the logging statement (see the Stack Trace below) is exactly what I'd expect. The line that is throwing the NPE is the one with "->" above.
I have SQL logging turned on, and here's what I get in the run log:
[2008-01-17 14:21:34,884] <WorkerThread3> PartUsage.sendToInventoryManagement - sendToInventoryManagement() called
[2008-01-17 14:21:34 EST] <WorkerThread3> === Begin Internal Transaction
[2008-01-17 14:21:34 EST] <WorkerThread3> evaluateExpression: <com.webobjects.jdbcadaptor.MicrosoftPlugIn$MicrosoftExpression: "SELECT t0.Part_Numbering_Code, t0.Part_Type_ID, t0.Part_Type_Name FROM dbo.Part_Type t0 WHERE t0.Part_Type_ID = ?" withBindings: 1:2(partTypeId)>
[2008-01-17 14:21:34 EST] <WorkerThread3> 1 row(s) processed
[2008-01-17 14:21:34 EST] <WorkerThread3> === Commit Internal Transaction
[2008-01-17 14:21:34,903] <WorkerThread3> PartUsage.sendToInventoryManagement - About to EXEC BM.dbo.ott_spInventoryAdjustment
@BatchID = 30481
@ItemNumber = 02070000000011
@QTY = 25.756700
@SiteID = WAREHOUSE
@Classification = Production
[2008-01-17 14:21:34 EST] <WorkerThread3> Server exception: null
[2008-01-17 14:21:34 EST] <WorkerThread3> java.lang.NullPointerException
at com.webobjects.eoaccess.EOUtilities.executeStoredProcedureNamed(EOUtilities.java:692)
at com.bestmaid.bakeryManagement.lotCodeTracking.PartUsage.sendToInventoryManagement(PartUsage.java:172)
at com.bestmaid.bakeryManagement.lotCodeTracking.PartUsage.clientSideRequestSendToInventoryManagement(PartUsage.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.foundation.NSSelector.invoke(NSSelector.java:354)
at com.webobjects.foundation.NSSelector._safeInvokeSelector(NSSelector.java:108)
at com.webobjects.eodistribution.common._EOServerInvocation.doInvokeWithTarget(_EOServerInvocation.java:140)
at com.webobjects.eodistribution.EODistributionContext._processClientRequest(EODistributionContext.java:488)
at com.webobjects.eodistribution.EODistributionContext.responseToClientMessage(EODistributionContext.java:577)
at com.webobjects.eodistribution.WOJavaClientComponent.handleClientRequest(WOJavaClientComponent.java:1105)
at com.webobjects.eodistribution.WOJavaClientComponent.invokeAction(WOJavaClientComponent.java:343)
at com.webobjects.appserver._private.WOComponentReference.invokeAction(WOComponentReference.java:104)
at com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:101)
at com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:110)
at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:945)
at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1168)
at com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1375)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedPage(WOComponentRequestHandler.java:196)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedSession(WOComponentRequestHandler.java:287)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedApplication(WOComponentRequestHandler.java:322)
at com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:358)
at com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:432)
at com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1306)
at com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:613)
Any ideas??
Thanks,
Dave