Developer forum

Forum » Development » Weird API big last night

Weird API big last night

Martin Nielsen
Reply

Hi DW,

 

We have a 100% custom import running on one of our big sites, and last night it gave a completely new error that doesn't seem to come from errors in our code, but from something inside the API.

 

The error i got was this:

[NullReferenceException: Object reference not set to an instance of an object.]
   Dynamicweb.eCommerce.Products.Group.GetGroupByID(String groupID, String languageID) +97
   DwEcomIntegration.App.Helper.getGroupByNumber(String number, String lang) in c:\GIT\Customer\DwEcomIntegration\DwEcomIntegration\App\Helper.cs:155
   DwEcomIntegration.ImportExport.EgeMovexImportVarerV2.Open() in c:\GIT\Customer\DwEcomIntegration\DwEcomIntegration\ImportExport\MovexImportVarerV2.cs:106
   Dynamicweb.Integration.Pipeline.Process() +280
   Dynamicweb.Admin.PipelineRunner1.Page_Load(Object sender, EventArgs e) +826
   System.Web.UI.Control.LoadRecursive() +70
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3063

So something inside

Dynamicweb.eCommerce.Products.Group.GetGroupByID(String groupID, String languageID)

gave a null exception.

 

I know for a fact that the group and language combination parsed into the method when it failed, returns a product. So the method doesn't look in the database for the group.

 

Any ideas what could be wrong?

 

// Martin

 


Replies

 
Morten Snedker
Reply

Hi Martin,

 

So, your're saying that GetGroupByID fails with the given error, but still it returns a group object (you write product, but i reckon you mean group)? Did I get that right?

 

 

On which version is this running?

 

/Snedker


 

 

 

 

 

 
Morten Bengtson
Reply
The GetGroupByID method does NOT select groups from the database but from a cached collection.

You need to either use the Group(IDataReader) constructor or keep track of the imported groups yourself. When the import is done the Group.ClearCache() method is called and the cached collection will be repopulated with groups by loading data from the database.

 
Martin Nielsen
Reply

@Morten S: Yes, i meant that the groupID and language i was trying to find, exists in the database, so the method gave a null exception, even when the group was in database.
The solution is running 8.2.3.10.

 

@Morten B: The group i was trying to find, isn't a group i'm importing, it was a group that is created manually many months ago. But i makes sense that newly created groups might not be in the cache yet.

 

 

Can i call Group.ClearCache() before i start my import, to make sure this doesn't happen again? And maybe again after

 
Morten Snedker
Reply

Martin, I was more thinking about the content of the two parameters you're sending along to the GetGroupByID method...you're sure you passed correct parameters?

 

And yes: surely you can clear the cache before import.

 

/Snedker

 

 

 
Martin Nielsen
Reply

Hi Morten,

 

I know that the parameters are correct, the part of the code that failed is semi hardcoded, and is looking for the same group each time the import runs. So i'm 100% sure the parameters are correct :-)

It's basicly the lookup for the parent group of the entire import that fails.

 

I'll add ClearCache to my code and hope that it prevents this issue in the future.

 

 

 

You must be logged in to post in the forum