Hello,

I think your problem might be the call to the name of the proc.
(the line)
NSDictionary outputArgs = EOUtilities.executeStoredProcedureNamed(ec, 
"[Server].[DBName].[dbo].[sp_Stored_Procedure]", inputArgs);

I am using a stored procedure in SQL Server
Here is the definition in the model:
{
    arguments = (
        {
            allowsNull = Y; 
            columnName = iAccountId; 
            externalType = char; 
            internalInfo = {_nameInObjectStore = 002; }; 
            name = accountId; 
            parameterDirection = 1; 
            valueClassName = NSString; 
            valueType = d; 
        }
    ); 
    externalName = sysdba.get_AssociationInfo; 
    name = getAssocInfo; 
}
Here is the code to use it:
    public static final String GET_ASSOC_INFO_PROC = "getAssocInfo";
    public static NSArray allAssocContactsForAccountId(final EOEditingContext 
anEditingContext, final String anAccountId) {
        final NSMutableArray results = new NSMutableArray();
        try {
            anEditingContext.lock();
            final NSArray temp = 
rawRowsForStoredProcedureNamed(anEditingContext, anAccountId, 
CoreContact.GET_ASSOC_INFO_PROC);
            final Enumeration enumeration = temp.objectEnumerator();
            while (enumeration.hasMoreElements()) {
                final NSDictionary element = 
(NSDictionary)enumeration.nextElement();
                final AssocContact contact = 
AssocContact.newInstance(anEditingContext);

// Some wakyness to build an eo
                contact.takeValuesFromDictionaryWithMapping(element, 
CRMObjectModel.mappingDictionaryForClassName(ClassUtils.getShortClassName(AssocContact.class)));
//

                results.addObject(contact);
            }
        } catch (final Exception e) {
            logger.error(e);
        } finally {
            anEditingContext.unlock();
        }
        return results;
    }

    private static NSArray rawRowsForStoredProcedureNamed(final 
EOEditingContext anEditingContext, final String anAccountId, final String 
aStoredProcedureName) {
        final NSMutableDictionary dict = new NSMutableDictionary();
        dict.takeValueForKey(anAccountId, CoreContact.ACCOUNT_ID);
        final NSArray temp = 
EOUtilities.rawRowsForStoredProcedureNamed(anEditingContext, 
aStoredProcedureName, dict);
        return temp;
    }


  
Jerry Porter
IT Distribution MS 34-202
Lincoln Financial Group
One Commerce Square
2005 Market Street
Philadelphia, PA 19103
(215) 255-7031



----- Original Message ----
From: David Avendasora <[EMAIL PROTECTED]>
To: WebObjects-Dev List <[email protected]>
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" +
    "[EMAIL PROTECTED] = " + inputArgs.valueForKey("@BatchID") + 
    "[EMAIL PROTECTED] = " + inputArgs.valueForKey("@ItemNumber") + 
    "[EMAIL PROTECTED] = " + inputArgs.valueForKey("@QTY") + 
    "[EMAIL PROTECTED] = " + inputArgs.valueForKey("@SiteID") + 
    "[EMAIL PROTECTED] = " + 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


      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to