Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : The "kernel" service is synthetic, it needs to be set at boot time before it can be used

Tags:

symfony

In our production website, I caught errors with sentry.io.

Since few month I have about 50 time the same error per day, but I never be able to reproduce it myself in local, preproduction, or even in production.

I have no clue what could throw that. I never had a client that reported me this error.

Does anyone knows what it could be?

ErrorException: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "kernel" service is synthetic, it needs to be set at boot time before it can be used. in /mnt/www/project/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:334
Stack trace:
#0 /mnt/www/project/app/cache/prod/Container2xhx4bk/appProdProjectContainer.php(11988): Symfony\Component\DependencyInjection\Container->get('kernel')
#1 /mnt/www/project/app/cache/prod/Container2xhx4bk/appProdProjectContainer.php(12085): Container2xhx4bk\appProdProjectContainer->getTemplating_LocatorService()
#2 /mnt/www/project/app/cache/prod/Container2xhx4bk/appProdProjectContainer.php(9670): Container2xhx4bk\appProdProjectContainer->getTwig_LoaderService()
#3 /mnt/www/project/app/cache/prod/Container2xhx4bk/appProdProjectContainer.php(9660): Container2xhx4bk\appProdProjectContainer->getTwigService()
#4 /mnt/www/project/ap
#1 vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php(334): handleFatalError
like image 632
Bouffe Avatar asked Jul 27 '18 12:07

Bouffe


1 Answers

You probably tried to get the kernel from the container before booting the kernel. Normally, a Symfony app starts by booting the kernel, then you can get the kernel from the container. Make sure you are booting it.

The kernel sets itself to the container on booting. Source: https://symfony.com/doc/current/service_container/synthetic_services.html

like image 166
diegowc Avatar answered Oct 22 '22 03:10

diegowc