3

After logged in to my Magento 2 admin, I got the below exception..

Can anyone help me to fix that issue?

1 exception(s):
Exception #0 (LogicException): Could not create an acl object: Invalid Document 
Element 'resource': The attribute 'title' is required but missing.
Line: 15

Exception #0 (LogicException): Could not create an acl object: Invalid Document 
Element 'resource': The attribute 'title' is required but missing.
Line: 15

#0 /home/xxxx/public_html/generated/code/Magento/Framework/Acl/Builder/Proxy.php(95): Magento\Framework\Acl\Builder->getAcl()
#1 /home/xxxx/public_html/vendor/magento/module-backend/Model/Auth/Session.php(227): Magento\Framework\Acl\Builder\Proxy->getAcl()
#2 /home/xxxx/public_html/vendor/magento/module-backend/Model/Auth.php(159): Magento\Backend\Model\Auth\Session->processLogin()
.......
2
  • can you please share your code in questions?
    – Abdul
    Dec 2, 2017 at 12:32
  • I am facing with this issue. can you tell me the way to fix this?
    – huykon225
    May 20, 2021 at 3:58

4 Answers 4

4

Just add title attribute.

Go to [namespace]/[vendor]/etc/acl.xml

Ex. Mycustom/Custom/etc/acl.xml

then add title.

 <resource id="Mycustom_Custom::test" title="My Custom" >
     <resource id="Mycustom_Custom::test" title="My Custom" />
 </resource>
3

To track down which module is causing the issue:

temp edit Magento\Framework\Config\Reader\Filesystem

at line 155 insert the validation routine:

if ($configMerger && !$configMerger->validate($this->_schemaFile, $errors)) {
                    $message = "Invalid Document \n";
                    throw new \Magento\Framework\Exception\LocalizedException(
                        new \Magento\Framework\Phrase($message . implode("\n", $errors))
                    );
                }

and then set a breakpoint to trap the error. then check the value of 'content' (the last ACL added)

enter image description here

2
  • Very nice. I simply added the key to the message to get the location of the faulty acl.xml like this $message = "Invalid Document location : ".$key."\n"; I do wish Magento would add proper file locations to their errors... Thank you for pointing me to the right code!
    – Isolde
    Sep 20, 2023 at 8:35
  • Let me add one more note: in my case the key (containing the location of the "faulty" acl) actually was the one after the actual faulty acl. So I added a $keyMinusOne variable to echo the location of the acl before the one throwing the error. That acl did not contain everything with the resource id="Magento_Backend::admin as it should have. Very happy with your answer @ProxiBlue, it saved me a lot of time
    – Isolde
    Sep 20, 2023 at 9:29
2

Check all of your custom and community modules code acl.xml file to check the missing title. Location of acl.xml is etc/acl.xml

Check whether a new resource id is created but title is missing for it. Example of a correct acl.xml

<?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="Company_Base::config"
                                      title="Company Module Settings"
                                      sortOrder="9999" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>
1
  • 5
    Why does Magento not tell us which xml file is the error? I know they are doing standard PHP DOM validation, but this is very annoying. I think they need to find a solution. Feb 16, 2018 at 8:24
0

Sandipan S is right but the important thing is how to find the wrong xml file. This process really tired me.

After many Google searches, I did not get any results. Finally, I applied the classic method.


The error I discovered was the use of Magento_Adminhtml.

Magento_Backend should have been used instead.


Here's what you need to do: You must narrow possible vendors and modules.

# Connect your server via SSH (with magento file owner user)
ssh {MagentoUser}@{YourServerNameOrIp}

# Go to your magento root (sample dir)
cd /var/www/html

# Move first custom vendor (or manny, if you want) avay to your user folder
# but be sure there is no folder exists named {Vendor} in your user folder
mv app/code/{Vendor1} /home/{MagentoUser}/{Vendor1}

# Test it
php bin/magento cache:flush && php bin/magento setup:upgrade

# If fails again move second
mv app/code/{Vendor2} /home/{MagentoUser}/{Vendor2}

# And test it
php bin/magento cache:flush && php bin/magento setup:upgrade

# Finally if not fails move vendors back in one by one from first
mv /home/{MagentoUser}/{Vendor1} ./app/code/{Vendor1} 

I hope it helps.

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.