SolvedPrestaShop 500 error: Kernel Container is not available

Describe the bug
After a payment (coming back from an external payment site), the payment module I am using calls PaymentModuleCore->validateOrder, which crashes with the exception "Kernel Container is not available".
This has happened since updating from 1.7.4.4 to 1.7.6.1.
It seems ContainerFinder was introduced between those versions

Stacktrace:

Fatal error: Uncaught Exception: Kernel Container is not available in /opt/bitnami/apps/prestashop/htdocs/src/Adapter/ContainerFinder.php:77 
Stack trace: 
#0 /opt/bitnami/apps/prestashop/htdocs/classes/Tools.php(796): PrestaShop\PrestaShop\Adapter\ContainerFinder->getContainer() 
#1 /opt/bitnami/apps/prestashop/htdocs/classes/Tools.php(773): ToolsCore::getContextLocale(Object(Context)) 
#2 /opt/bitnami/apps/prestashop/htdocs/classes/PaymentModule.php(421): ToolsCore::displayPrice(1.05, Object(Currency), false) 
#3 /opt/bitnami/apps/prestashop/htdocs/modules/sagepay/validation.php(85): PaymentModuleCore->validateOrder(20035, '2', 1.26, 'Sagepay', 'Result:OK<br />...', Array, NULL, false, 'REDACTED') 
#4 {main} thrown in /opt/bitnami/apps/prestashop/htdocs/src/Adapter/ContainerFinder.php on line 77

Additional information
PrestaShop version: 1.7.6.1
PHP version: 7.1.22

17 Answers

✔️Accepted Answer

Hi @TedEriksson
Checking out the diff for 1.7.6 in the payment module I use (mobilpay), I see they are initializing the kernel in validation.php:
image

    global $kernel;
    if(!$kernel){ 
      require_once _PS_ROOT_DIR_.'/app/AppKernel.php';
      $kernel = new \AppKernel('prod', false);
      $kernel->boot(); 
    }

Maybe you can implement this behaviour in your module.

More Issues: