0

I'm getting this error message when trying to access the admin:

1 exception(s): Exception #0 (LogicException): Could not create an acl object: The XML in file "C:/xampp/htdocs/magento2-dshop/app/code/Dshop/ModuloBasico/etc/acl.xml" is invalid: Element 'config', attribute '{http://www.w3.org/2001/XMLSchema-instance}noNamespaceShcemaLocation': The attribute '{http://www.w3.org/2001/XMLSchema-instance}noNamespaceShcemaLocation' is not allowed. Line: 2

Verify the XML and try again.

Exception #0 (LogicException): Could not create an acl object: The XML in file "C:/xampp/htdocs/magento2-dshop/app/code/Dshop/ModuloBasico/etc/acl.xml" is invalid: Element 'config', attribute '{http://www.w3.org/2001/XMLSchema-instance}noNamespaceShcemaLocation': The attribute '{http://www.w3.org/2001/XMLSchema-instance}noNamespaceShcemaLocation' is not allowed. Line: 2

Verify the XML and try again.

#1 Magento\Framework\Acl\Builder\Proxy->getAcl() called at [vendor\magento\module-backend\Model\Auth\Session.php:261]
#2 Magento\Backend\Model\Auth\Session->processLogin() called at [generated\code\Magento\Backend\Model\Auth\Session\Interceptor.php:77]
#3 Magento\Backend\Model\Auth\Session\Interceptor->processLogin() called at [vendor\magento\module-backend\Model\Auth.php:165]
#4 Magento\Backend\Model\Auth->login() called at [vendor\magento\framework\Interception\Interceptor.php:58]
#5 Magento\Backend\Model\Auth\Interceptor->___callParent() called at [vendor\magento\framework\Interception\Interceptor.php:138]
#6 Magento\Backend\Model\Auth\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor\magento\framework\Interception\Interceptor.php:153]
#7 Magento\Backend\Model\Auth\Interceptor->___callPlugins() called at [generated\code\Magento\Backend\Model\Auth\Interceptor.php:59]
#8 Magento\Backend\Model\Auth\Interceptor->login() called at [vendor\magento\module-backend\App\Action\Plugin\Authentication.php:205]
#9 Magento\Backend\App\Action\Plugin\Authentication->_performLogin() called at [vendor\magento\module-backend\App\Action\Plugin\Authentication.php:157]
#10 Magento\Backend\App\Action\Plugin\Authentication->_processNotLoggedInUser() called at [vendor\magento\module-backend\App\Action\Plugin\Authentication.php:125]
#11 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() called at [vendor\magento\framework\Interception\Interceptor.php:135]
#12 Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor\magento\framework\Interception\Interceptor.php:153]
#13 Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->___callPlugins() called at [generated\code\Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor.php:32]
#14 Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->dispatch() called at [vendor\magento\framework\App\FrontController.php:186]
#15 Magento\Framework\App\FrontController->processRequest() called at [vendor\magento\framework\App\FrontController.php:118]
#16 Magento\Framework\App\FrontController->dispatch() called at [vendor\magento\framework\Interception\Interceptor.php:58]
#17 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor\magento\framework\Interception\Interceptor.php:138]
#18 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor\magento\framework\Interception\Interceptor.php:153]
#19 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated\code\Magento\Framework\App\FrontController\Interceptor.php:23]
#20 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor\magento\framework\App\Http.php:116]
#21 Magento\Framework\App\Http->launch() called at [generated\code\Magento\Framework\App\Http\Interceptor.php:23]
#22 Magento\Framework\App\Http\Interceptor->launch() called at [vendor\magento\framework\App\Bootstrap.php:263]
#23 Magento\Framework\App\Bootstrap->run() called at [index.php:29]

This is just for a very simple admin module I'm trying to create following a Magento 2 tutorial.

This is the structure for the module:

Module structure

acl.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceShcemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::marketing">
                    <resource
                        id="Dshop_ModuloBasico::dshopbackend"
                        title="DshopBackend" sortOrder="60">
                        <resource id="Dshop_ModuloBasico::index" title="DshopBackend index" />                        
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

Index.php

<?php

namespace Dshop\ModuloBasico\Controller\Adminhtml\Index;

use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class Index extends \Magento\Backend\App\Action
{
    protected $resultPageFactory;

    public function __construct(
        Context $context,
        PageFactory $resultPageFactory
    ){
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        $resultPage = $this->resultPageFactory->create();
        return $resultPage;
    }

    public function _isAllowed()
    {
        return $this->_authorization->isAllowed('Dshop_ModuloBasico::index');
    }
}

menu.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add
            id="Dshop_ModuloBasico::dshopbackend"
            title="DshopBackend"
            module="Dshop_ModuloBasico"
            sortOrder="50"
            parent="Magento_Backend::marketing"
            resource="Dshop_ModuloBasico::dshopbackend"
        />
        <add
            id="Dshop_ModuloBasico::index"
            title="DshopBackend Index"
            module="Dshop_ModuloBasico"
            sortOrder="51"
            parent="Dshop_ModuloBasico::dshopbackend"
            action="dshopadmin/index/"
            resource="Dshop_ModuloBasico::index"
        />
    </menu>
</config>

routes.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="dshopadmin" frontName="dshopadmin">
            <module name="Dshop_ModuloBasico" before="Magento_Backend" />
        </route>
    </router>
</config>

module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Dshop_ModuloBasico" setup_version="1.0.0"></module>
</config>

registration.php

<?php
    \Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Dshop_ModuloBasico',
    __DIR__
);

No idea what I'm doing wrong here.

Any help would be appreciated!

1 Answer 1

0

You have a typo in acl.xml file: noNamespaceShcemaLocation should be changed to noNamespaceSchemaLocation

So finally your acl.xml file will looks like this:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceShcemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
    <resources>
        <resource id="Magento_Backend::admin">
            <resource id="Magento_Backend::marketing">
                <resource
                    id="Dshop_ModuloBasico::dshopbackend"
                    title="DshopBackend" sortOrder="60">
                    <resource id="Dshop_ModuloBasico::index" title="DshopBackend index" />                        
                </resource>
            </resource>
        </resource>
    </resources>
</acl>
</config>
3
  • @Abi If this answer helps you resolve your issue, please mark it as accepted. That indicates your issue is solved and helps others with the same issue find out the verified answer easily. You can do that by ticking the check symbol at the top-left corner of my answer.
    – Tu Van
    Nov 25, 2022 at 5:18
  • Ok this is very weird. I didn't notice the typo since I basically copied and pasted the code from the tutorial I'm following and it has the typo in there. However, for some reason, it worked for the tutorial guy. Then, before fixing the typo in my code I went and tried to access the admin again, and it was working! Without fixing the typo lol idk why. I still fixed the typo though just in case. Thank you!
    – Abi
    Nov 26, 2022 at 4:21
  • I think the guy who shares that tutorial had a typo when writing the tutorial. You can read the error message to know the reason: The XML in file ....etc/acl.xml is invalid: Element 'config', attribute '{w3.org/2001/XMLSchema-instance}noNamespaceShcemaLocation': The attribute '{w3.org/2001/XMLSchema-instance}noNamespaceShcemaLocation' is not allowed. Line: 2
    – Tu Van
    Nov 26, 2022 at 4:46

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.