0

I get the following error if I load my homepage, after I upgraded from 2.4.5 to 2.4.5-p1:

Error: Cannot instantiate abstract class Magento\Framework\Model\ResourceModel\AbstractResource in /var/www/html/company_245/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
Stack trace:
#0 /var/www/html/company_245/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject()
#1 /var/www/html/company_245/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create()
#2 /var/www/html/company_245/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get()
#3 /var/www/html/company_245/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create()
#4 /var/www/html/company_245/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get()
#5 /var/www/html/company_245/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create()
#6 /var/www/html/company_245/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get()
#7 /var/www/html/company_245/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Compiled->create()
#8 /var/www/html/company_245/vendor/magento/framework/View/Element/BlockFactory.php(44): Magento\Framework\ObjectManager\ObjectManager->create()
#9 /var/www/html/company_245/vendor/magento/framework/View/Layout/Generator/Block.php(272): Magento\Framework\View\Element\BlockFactory->createBlock()
#10 /var/www/html/company_245/vendor/magento/framework/View/Layout/Generator/Block.php(252): Magento\Framework\View\Layout\Generator\Block->getBlockInstance()
#11 /var/www/html/company_245/vendor/magento/framework/View/Layout/Generator/Block.php(229): Magento\Framework\View\Layout\Generator\Block->createBlock()
#12 /var/www/html/company_245/vendor/magento/framework/View/Layout/Generator/Block.php(134): Magento\Framework\View\Layout\Generator\Block->generateBlock()
#13 /var/www/html/company_245/vendor/magento/framework/View/Layout/GeneratorPool.php(93): Magento\Framework\View\Layout\Generator\Block->process()
#14 /var/www/html/company_245/vendor/magento/framework/View/Layout.php(365): Magento\Framework\View\Layout\GeneratorPool->process()
#15 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->generateElements()
#16 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent()
#17 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}()
#18 /var/www/html/company_245/generated/code/Magento/Framework/View/Layout/Interceptor.php(32): Magento\Framework\View\Layout\Interceptor->___callPlugins()
#19 /var/www/html/company_245/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
#20 /var/www/html/company_245/vendor/magento/framework/View/Page/Builder.php(65): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
#21 /var/www/html/company_245/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
#22 /var/www/html/company_245/vendor/magento/framework/View/Layout.php(271): Magento\Framework\View\Layout\Builder->build()
#23 /var/www/html/company_245/vendor/magento/framework/View/Layout.php(896): Magento\Framework\View\Layout->build()
#24 /var/www/html/company_245/vendor/magento/module-cms/Helper/Page.php(216): Magento\Framework\View\Layout->getBlock()
#25 /var/www/html/company_245/vendor/magento/module-cms/Controller/Index/Index.php(74): Magento\Cms\Helper\Page->prepareResultPage()
#26 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Cms\Controller\Index\Index->execute()
#27 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cms\Controller\Index\Index\Interceptor->___callParent()
#28 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}()
#29 /var/www/html/company_245/generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php(23): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins()
#30 /var/www/html/company_245/vendor/magento/framework/App/Action/Action.php(111): Magento\Cms\Controller\Index\Index\Interceptor->execute()
#31 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()
#32 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cms\Controller\Index\Index\Interceptor->___callParent()
#33 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}()
#34 /var/www/html/company_245/generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php(32): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins()
#35 /var/www/html/company_245/vendor/magento/framework/App/FrontController.php(245): Magento\Cms\Controller\Index\Index\Interceptor->dispatch()
#36 /var/www/html/company_245/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#37 /var/www/html/company_245/vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()
#38 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#39 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#40 /var/www/html/company_245/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#41 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()
#42 /var/www/html/company_245/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(71): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#43 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#44 /var/www/html/company_245/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#45 /var/www/html/company_245/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#46 /var/www/html/company_245/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#47 /var/www/html/company_245/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#48 /var/www/html/company_245/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#49 {main}

I tried:

  1. delete vendor folder
  2. composer clearcache
  3. composer install
  4. php bin/magento setup:upgrade
  5. php bin/magento setup:di:compile

But the error is still there.

I even downgraded to 2.4.5 again but I still get the error.

4 Answers 4

3

This happens when any of our custom or third party extension has default parameter in between for __construct() arguments instead of at the end.

Please check which action you're performing while getting this error. One of the classes involved in this action can have a default parameter in between, like below:

enter image description here

Need to move array $data = [] at the last position because it has a default value.

1

Steps To Reproduce

  • check the PHP version compatibility with Magento 2.4.5-p1

  • Check the Full Logs

  • Check any third party extension may conflict with Magento 2.4.5-p1

  • First, fix the optional parameter issue that you can have in PHP 8.1 i.e. rearrange the constructor: Pass the optional parameters after the required parameters i.e

    my__construct(...., $optional)

  • Then, before performing the above steps, I would remove the vendor directory or rename the directory and launch the terminal again and execute the command

    composer install

to regenerate all the Magento standard codes. You can check your vendor folder to make sure laminas are installed and run the compilation command later to load the dependencies.

5
  • I downgraded to 2.4.5 again, but I still get the error...
    – Black
    Commented Feb 14, 2023 at 11:26
  • Did you Remove Vendor and run the composer update again? Commented Feb 14, 2023 at 11:58
  • Yes, I removed vendor again and executed composer install
    – Black
    Commented Feb 14, 2023 at 15:22
  • The problem is due to one of our own extensions which is not compatible to 2.4.5 anymore.
    – Black
    Commented Feb 14, 2023 at 15:58
  • 1
    Perfect sounds your problem is solved. Commented Feb 15, 2023 at 8:10
1

The problem was due to one of our own extensions which used Magento\Framework\Model\ResourceModel\AbstractResource. We have no clue why the error is thrown though and need to investigate it further.

We disabled the module for now.

1
  • did you find out what the problem was? I have the same problem
    – jim smith
    Commented Oct 30, 2023 at 17:46
0

I had this error after update to 2.4.6 due to extending my custom module's model with Magento\Framework\Model\AbstractModel. In my case it was due to order of parameters in the model's __construct method - it should be custom first and then parent class parameters.

When it looked like this I was getting the error:

public function __construct(
    \Magento\Framework\Model\Context $context,
    \Magento\Framework\Registry $registry,
    \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
    \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    array $data = []
) {
    $this->_storeManager = $storeManager;
    parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}

So I've changed the parameters order and the error went away:

    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Framework\Model\Context $context,
    \Magento\Framework\Registry $registry,
    \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
    \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
    array $data = []

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.