0

On login to Magento 2.1 admin I get following error .

   1 exception(s):

    Exception #0 (LogicException): Could not create an acl object: Invalid Document 
    Element 'admin': This element is not expected. Expected is ( resource ).
    Line: 5


    Exception #0 (LogicException): Could not create an acl object: Invalid Document 
    Element 'admin': This element is not expected. Expected is ( resource ).
    Line: 5   

    #0 /var/www/html/Dir/var/generation/Magento/Framework/Acl/Builder/Proxy.php(95): Magento\Framework\Acl\Builder->getAcl()
#1 /var/www/html/Dir/vendor/magento/module-backend/Model/Auth/Session.php(221): Magento\Framework\Acl\Builder\Proxy->getAcl()
#2 /var/www/html/Dir/var/generation/Magento/Backend/Model/Auth/Session/Interceptor.php(102): Magento\Backend\Model\Auth\Session->processLogin()
#3 /var/www/html/Dir/vendor/magento/module-backend/Model/Auth.php(156): Magento\Backend\Model\Auth\Session\Interceptor->processLogin()
#4 /var/www/html/Dir/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Backend\Model\Auth->login('*****', '*****')
#5 /var/www/html/Dir/var/generation/Magento/Backend/Model/Auth/Interceptor.php(78): Magento\Backend\Model\Auth\Interceptor->___callPlugins('login', Array, Array)
#6 /var/www/html/Dir/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(205): Magento\Backend\Model\Auth\Interceptor->login('*****', '*****')
#7 /var/www/html/Dir/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(157): Magento\Backend\App\Action\Plugin\Authentication->_performLogin(Object(Magento\Framework\App\Request\Http))
#8 /var/www/html/Dir/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(125): Magento\Backend\App\Action\Plugin\Authentication->_processNotLoggedInUser(Object(Magento\Framework\App\Request\Http))
#9 /var/www/html/Dir/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#10 /var/www/html/Dir/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Backend...', 'dispatch', Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor), Array, 'adminMassaction...')
#11 /var/www/html/Dir/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#12 /var/www/html/Dir/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#13 /var/www/html/Dir/var/generation/Magento/Backend/Controller/Adminhtml/Index/Index/Interceptor.php(39): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#14 /var/www/html/Dir/vendor/magento/framework/App/FrontController.php(55): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#15 /var/www/html/Dir/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#16 /var/www/html/Dir/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#17 /var/www/html/Dir/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#18 /var/www/html/Dir/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#19 /var/www/html/Dir/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#20 /var/www/html/Dir/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#21 /var/www/html/Dir/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#22 /var/www/html/Dir/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#23 /var/www/html/Dir/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#24 {main}

How to debug it and find the root cause that is which acl file is creating this issue?

2
  • 1
    this seems like an external module failure, having an invalid etc/acl.xml file May 17, 2017 at 20:31
  • @DavidVerholen Do you know how can I debug this?
    – Mukesh
    May 18, 2017 at 5:52

2 Answers 2

1

I had the same problem with my custom plugin and solved it. So just want to share how I solved it if anyone gets the same issue.

This was my error after logging in into admin dashboard:

1 exception(s):
Exception #0 (LogicException): Could not create an acl object: The XML in file "/home/magento2/app/code/Mycustommodule/Mymodulejs/etc/acl.xml" is invalid:
Element 'admin': This element is not expected. Expected is ( resource ).
Line: 5

Verify the XML and try again.

Exception #0 (LogicException): Could not create an acl object: The XML in file "/home/magento2/app/code/Mycustommodule/Mymodulejs/etc/acl.xml" is invalid:
Element 'admin': This element is not expected. Expected is ( resource ).
Line: 5

Verify the XML and try again.
#0 /home/magento2/generated/code/Magento/Framework/Acl/Builder/Proxy.php(95): Magento\Framework\Acl\Builder->getAcl()
#1 /home/magento2/app/code/Magento/Backend/Model/Auth/Session.php(227): Magento\Framework\Acl\Builder\Proxy->getAcl()
#2 /home/magento2/app/code/Magento/Backend/Model/Auth.php(165): Magento\Backend\Model\Auth\Session->processLogin()
#3 /home/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Backend\Model\Auth->login('admin', '0omochl@1WA')
#4 /home/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Backend\Model\Auth\Interceptor->___callParent('login', Array)
#5 /home/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Backend\Model\Auth\Interceptor->Magento\Framework\Interception\{closure}('admin', '0omochl@1WA')
#6 /home/magento2/generated/code/Magento/Backend/Model/Auth/Interceptor.php(26): Magento\Backend\Model\Auth\Interceptor->___callPlugins('login', Array, Array)
#7 /home/magento2/app/code/Magento/Backend/App/Action/Plugin/Authentication.php(205): Magento\Backend\Model\Auth\Interceptor->login('admin', '0omochl@1WA')
#8 /home/magento2/app/code/Magento/Backend/App/Action/Plugin/Authentication.php(157): Magento\Backend\App\Action\Plugin\Authentication->_performLogin(Object(Magento\Framework\App\Request\Http))
#9 /home/magento2/app/code/Magento/Backend/App/Action/Plugin/Authentication.php(125): Magento\Backend\App\Action\Plugin\Authentication->_processNotLoggedInUser(Object(Magento\Framework\App\Request\Http))
#10 /home/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#11 /home/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#12 /home/magento2/generated/code/Magento/Backend/Controller/Adminhtml/Index/Index/Interceptor.php(26): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->___callPlugins('dispatch', Array, NULL)
#13 /home/magento2/lib/internal/Magento/Framework/App/FrontController.php(159): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#14 /home/magento2/lib/internal/Magento/Framework/App/FrontController.php(99): Magento\Framework\App\FrontController->processRequest(Object(Magento\Framework\App\Request\Http), Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor))
#15 /home/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#16 /home/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#17 /home/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#18 /home/magento2/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#19 /home/magento2/lib/internal/Magento/Framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#20 /home/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#21 /home/magento2/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#22 {main}

Problematic acl.xml file:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <mycustommodule translate="title" module="Mycustommodule_Mymodulejs">
                                        <title>MyModule.js Options</title>
                                        <sort_order>1</sort_order>
                                    </mycustommodule>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>

Then I've just modified it to:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::stores">
                    <resource id="Magento_Backend::stores_settings">
                        <resource id="Magento_Config::config">
                            <resource id="Mycustommodule_Mymodulejs::modulejs" title="MyModule.js Options" sortOrder="1" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

So on the end, it seems that the problem is that I was using an old AccessControlLists (acl.xml) structure from Magento 1 which is changed in Magento 2 and not accepted.

More info here in Mageplaza documentation - Magento 2 Admin ACL Access Control Lists

1

I followed the following approach to debug this issue.

1) By reading the line Could not create an acl object I know its ACL related issue.

2) By reading Element 'admin': This element is not expected. Expected is ( resource ). its known that the issue is with element admin

3) Line: 5 Indicate that the issue is in line 5 of an ACL file.

4) So I searched in all the acl.xml files for the element admin.

I found it in an acl.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <admin>      <!-- This is line 5 and element is admin. This is Magento 1 way -->
                <children>
                    <epicor_common module="epicor_common">
                        <children>
                            <elements>
                                <title>Elements</title>
                                <children>
                                    <elements_transaction>
                                        <title>Transaction</title>
                                    </elements_transaction>
                                </children>
                            </elements>
                        </children>
                    </epicor_common>
                </children>
            </admin>
        </resources>
    </acl>
</config>

After fixing the acl.xml file it worked for me. Syntax of Magento1 ACL and Magento2 ACL is different.

2
  • How did you solved this error? Why is admin element problematic?
    – BlueDev
    Feb 17, 2019 at 8:00
  • @BlueDev <admin> node is wrong in Magento 2
    – Mukesh
    Feb 18, 2019 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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