9

I am on Magento 2.2.3. I tried to install the Ultimo theme and got this error. I realized it would not work for me. I went ahead and removed the theme and now receive this-

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'reference': This element is not expected.
Line: 1


Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'reference': This element is not expected.
Line: 1

#0 /var/www/html/vendor/magento/framework/Config/Dom.php(115): Magento\Framework\Config\Dom->_initDom('<layout xmlns:x...')
#1 /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(111): Magento\Framework\Config\Dom->__construct('<layout xmlns:x...', Object(Magento\Framework\App\Arguments\ValidationState), Array, NULL, '/var/www/html/w...', '%message%\nLine:...')
#2 /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)
#3 /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...', Array)
#4 /var/www/html/vendor/magento/framework/Config/DomFactory.php(42): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Framewo...', Array)
#5 /var/www/html/vendor/magento/framework/View/Model/Layout/Update/Validator.php(141): Magento\Framework\Config\DomFactory->createDom(Array)
#6 /var/www/html/vendor/magento/framework/View/Model/Layout/Merge.php(461): Magento\Framework\View\Model\Layout\Update\Validator->isValid('<layout xmlns:x...', 'layout_merged', false)
#7 /var/www/html/vendor/magento/framework/View/Model/Layout/Merge.php(442): Magento\Framework\View\Model\Layout\Merge->_validateMergedLayout('LAYOUT_frontend...', '<reference name...')
#8 /var/www/html/generated/code/Magento/Framework/View/Model/Layout/Merge/Interceptor.php(193): Magento\Framework\View\Model\Layout\Merge->load(Array)
#9 /var/www/html/vendor/magento/framework/View/Layout/Builder.php(86): Magento\Framework\View\Model\Layout\Merge\Interceptor->load()
#10 /var/www/html/vendor/magento/framework/View/Layout/Builder.php(63): Magento\Framework\View\Layout\Builder->loadLayoutUpdates()
#11 /var/www/html/vendor/magento/framework/View/Layout.php(254): Magento\Framework\View\Layout\Builder->build()
#12 /var/www/html/vendor/magento/framework/View/Layout.php(875): Magento\Framework\View\Layout->build()
#13 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(414): Magento\Framework\View\Layout->getBlock('page_content_he...')
#14 /var/www/html/vendor/magento/module-cms/Helper/Page.php(171): Magento\Framework\View\Layout\Interceptor->getBlock('page_content_he...')
#15 /var/www/html/vendor/magento/module-cms/Controller/Index/Index.php(43): Magento\Cms\Helper\Page->prepareResultPage(Object(Magento\Cms\Controller\Index\Index\Interceptor), 'new-home')
#16 /var/www/html/generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php(24): Magento\Cms\Controller\Index\Index->execute(NULL)
#17 /var/www/html/vendor/magento/framework/App/Action/Action.php(107): Magento\Cms\Controller\Index\Index\Interceptor->execute()
#18 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#19 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cms\Controller\Index\Index\Interceptor->___callParent('dispatch', Array)
#20 /var/www/html/vendor/magento/module-customer-segment/Model/App/Action/ContextPlugin.php(81): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))

I only receive it in developer mode, in production mode everything works fine. This is the issue- https://github.com/magento/magento2/issues/11194#issuecomment-333978626 what I can't find is where the 'reference' is. How do I locate it?

6 Answers 6

8

This error indicates that somewhere in your XML layout files you have element <reference/>, which is not allowed. You can search for all occurrences of '<reference ' in your /app folder (*.xml).

If you can't find it, then it is possible that you have entered <reference> element in admin in XML Layout update field somewhere (Category, CMS Page, etc.), in this case you'll only get error on that page / category. If you have error on Home page, check 'Layout Update XML' field for Page with 'home' URL key.

2

Referring to answer @kovinet, I might add that if you look for this construct in the project code, you may not find anything similar. You need to check it in the database, open the "cms_page" table, find the page where you have this problem and find the column "layout_update_xml". In this column we see this code related to construction, see the screenshot, maybe the problem can be hidden in this place. In my case, I deleted everything from column "layout_update_xml", run bin/magento setup:upgrade && bin/magento setup:di:compile, refresh page, and the CMS page loaded without errors. enter image description here

0
0

After removed the Ultimo theme you need to run the below ssh commands in your magento root directory:

rm -rf var/*
rm -rf pub/static/*
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
chmod -R 777 var pub/static
php bin/magento cache:flush

I hope it will work.

1
  • Went through and I still got the same error. I need to open up php storm and do a search, just not sure what for.
    – tjjen
    Commented Mar 13, 2018 at 15:21
0

Old question, however if this happens after you open up a product on the frontend of the store after a migration, it has migrated custom_layout code. This will also cause the same error to be reported. Scan catalog_product_varchar value for %%

0

Check table catalog_product_entity_text and attribute_code custom_layout_update by id. In value can be <reference then you must delete all rows from table if they exists because they have wrong tag, clear cache and try again load page.table catalog_product_entity_text

4
  • This answer is not very clear about how to proceed with the queries and can be hard to understand for a beginner on Magento. After getting this result, it is not clear about what to do with it (without looking at the other answers). Could you elaborate a bit more please ?
    – Cladiuss
    Commented Aug 3, 2023 at 12:37
  • @Cladiuss You must delete all rows from table if they exists because they have wrong <reference> tag, clear cache and try again load page. It helps for me Commented Aug 11, 2023 at 14:17
  • Can you edit your answer to add this details ?
    – Cladiuss
    Commented Aug 11, 2023 at 14:41
  • @Cladiuss I edited my answer Commented Aug 14, 2023 at 19:10
0

Query this

  SELECT * FROM `cms_page` WHERE `layout_update_xml` LIKE '%<reference%'

then remove all the values from layout_update_xml table. then

bin/magento setup:upgrade && bin/magento setup:di:compile 

refresh and it should work if you have this error in homepage.

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.