Expand my Community achievements bar.

SOLVED

custom Adobe CQ commerce provider

Avatar

Level 2

Hi, 

we applied the instructions as found in tutorial http://helpx.adobe.com/experience-manager/using/creating-custom-cq-commerce-providers.html. The idea is to extend or enhance the default OOTB Adobe commerce provider. According to the javadoc this is a quote "a simple cart pricing architecture with single currency" unquote and FYI .... the hard-coded VAT rate of 6% is not very applicable for European customers .... 

By now, I'm getting rather used to the open-for-improvement-coding-techniques (plenty of unused variables, poor Java-naming conventions) but the NPE (null pointer exception) is especially annoying. this exception is being produced when the TrainingCommerceSessionImpl constructor invoked (invoking the super AbstractJcrCommerceSession constructor) and my suspicion is this NPE is part of this constructor. 

Please note we are using AEM 6.0 and I noticed the corresponding API has changed quite a bit between version 5.6 and version 6.0 

many thanks for helping us out, 

Wim 

1 Accepted Solution

Avatar

Correct answer by
Level 10

The  http://helpx.adobe.com/experience-manager/using/creating-custom-cq-commerce-providers.html article that you referenced is for 5.6 as specified in the article summary. An updated article will be available for 6. 

View solution in original post

6 Replies

Avatar

Level 10

Make sure you are using AbstractJcrCommerceService(ServiceContext serviceContext) and not deprecated one. 

Avatar

Level 1

Thanks for the reply but would it be possible to to be a bit more specific on this?  The class TrainingCommerceSessionImpl extends AbstractJcrCommerceSession and there is rather little space to apply changes or your recommended change.

In parallel, by now, I'm rather in favor of enhancing / adapting the Adobe code directly instead of applying the tutorial. The only thing the tutorial gives me is a modified getSKU method returning a hard coded String. By adapting the actual Adobe class I'll be able to enhance the logic with regards to VAT calculation. We'll obviously have to apply this logic with every single new shipment from Adobe but I'm fairly convinced this is, by far, the most pragmatic approach.   

thanks again, 

Wim 

Avatar

Level 2

I'm close to giving up on this. Please note a very similar thread exists : http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage... and this thread confirms the problem of the NPE as well. 

I made sure my serviceContext is set and I included debugging on all 4 parameters (passed as an argument when invoking the AbstractJcrCommerceSession constructor). 

Please see the attached snippet of the error log. Problem is in the constructor and line to be validated is line 146. I decompiled different versions of the AbstractJcrCommerceSession class but somehow I'm not able to spot the correct one but by looking at the code I'm not really surprised a null pointer exception is being generated since the return value of multiple methods isn't checked at all .... 

best regards,

Wim 

Avatar

Correct answer by
Level 10

The  http://helpx.adobe.com/experience-manager/using/creating-custom-cq-commerce-providers.html article that you referenced is for 5.6 as specified in the article summary. An updated article will be available for 6. 

Avatar

Level 2

Point taken and point is entirely valid. I tested on AEM 5.6 and I'm quite happy to confirm the tutorial is entirely correct and allowed me to change/enhance the commerce implementation. I noticed the AbsttractJcrCommerceSession's constructor retrieves the language (and afterwards the related country) starting from the serviceContext and maybe, assuming it's possible the language hasn't been set for a particular user, this explains why other people hit a Null Pointer Exception (as explained in the second thread). 

 

Please find attached a small class diagram that might be useful for other people. I used a new UML editor today for the very first time so it's certainly possible to improve this diagram a tad. 

Apologies for the not entire valid analysis and thanks for the fast responses. 

regards,

Wim