Score:1

How to solve this error "Class \Drupal\simple_sitemap\Controller\SimpleSitemapController does not exist"

tr flag

I got this error which is kind of surprising to me since I don't have it on my local environment. What I did is that I compressed the project directory and uploaded it to my cpanel file manager and then extract it. I then imported the sql file to phpmyadmin and made the credential match the ones on my production server.

When I open my site, it was working on the front page and other pages created with the Content type Basic pages. However, when I navigate to /user/login, this error appears. It also appeared on webform pages.

The website encountered an unexpected error. Please try again later. Error: Class 'Drupal\simple_sitemap\Queue\SimpleSitemapQueue' not found in Drupal\Component\DependencyInjection\Container->createService() (line 262 of core/lib/Drupal/Component/DependencyInjection/Container.php). Drupal\Component\DependencyInjection\Container->createService(Array, 'simple_sitemap.queue') (Line: 176) Drupal\Component\DependencyInjection\Container->get('simple_sitemap.queue', 1) (Line: 437) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 240) Drupal\Component\DependencyInjection\Container->createService(Array, 'simple_sitemap.queue_worker') (Line: 176) Drupal\Component\DependencyInjection\Container->get('simple_sitemap.queue_worker', 1) (Line: 437) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 240) Drupal\Component\DependencyInjection\Container->createService(Array, 'simple_sitemap.generator') (Line: 176) Drupal\Component\DependencyInjection\Container->get('simple_sitemap.generator', 1) (Line: 437) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 240) Drupal\Component\DependencyInjection\Container->createService(Array, 'simple_sitemap.form_helper') (Line: 176) Drupal\Component\DependencyInjection\Container->get('simple_sitemap.form_helper') (Line: 198) Drupal::service('simple_sitemap.form_helper') (Line: 43) simple_sitemap_form_alter(Array, Object, 'webform_submission_contact_node_25_add_form') (Line: 539) Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'webform_submission_contact_node_25_add_form') (Line: 836) Drupal\Core\Form\FormBuilder->prepareForm('webform_submission_contact_node_25_add_form', Array, Object) (Line: 279) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48) Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add') (Line: 1230) Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 18) Drupal\webform\WebformEntityViewBuilder->view(Object, 'default') (Line: 165) Drupal\entity_block\Plugin\Block\EntityBlock->build() (Line: 105) Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender(Object, 'section_component.build.render_array', Object) call_user_func(Array, Object, 'section_component.build.render_array', Object) (Line: 142) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'section_component.build.render_array') (Line: 90) Drupal\layout_builder\SectionComponent->toRenderArray(Array, ) (Line: 86) Drupal\layout_builder\Section->toRenderArray(Array) (Line: 317) Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildSections(Object) (Line: 276) Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 340) Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 24) Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 282) Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239) Drupal\Core\Entity\EntityViewBuilder->build(Array) call_user_func_array(Array, Array) (Line: 101) Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 786) Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 377) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201) Drupal\Core\Render\Renderer->render(Array, ) (Line: 241) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent{closure}() (Line: 578) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242) Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132) Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90) Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) call_user_func(Array, Object, 'kernel.view', Object) (Line: 142) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 191) Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 128) Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 82) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I searched and found some articles which says that clearing cache will solve the issue. I cannot login to the interface so I ran /core/rebuild.php but it doesn't solve it.

When I ran drush cr on the command line, I got this error.

In EntityResolverManager.php line 128:
Class \Drupal\simple_sitemap\Controller\SimpleSitemapController does not exist

On my local environment I used Lando with Varbase, which is based on Drupal 9.

Score:2
sd flag

What happened was, we (maintainers of the module) renamed a few class names from Simplesitemap to SimpleSitemap (CamelCase). Apparently certain case insensitive environments like Windows and in some cases OSX disregard letter case changes.

If you are transferring files through FTP, the solution is to make sure the files arrive with the correct case, by e.g. deleting the old files instead of overwriting them.

If you use git to push changes and you have this problem, ensure your host computer has git's ignorecase set to false: git config core.ignorecase false

There is a support ticket you can read through with a couple of solutions.

Score:0
nr flag

Cpanel makes this tough. But it is definitely possible to ask your hosting provider for Secure SHell (SSH) access to the Cpanel server. Once you have that, you can download Drush -- I don't expect you'll have Composer on Cpanel, so skip a step and download the Drush PHAR appropriate to your Drupal version (probably the latest Drush 10 unless you are still on Drupal 7 or lower). Once you have Drush, you'll have many options (to rebuild caches, apply database schema updates, and repair various things) which are not available via the web browser.

Since the error is related to the Simple Sitemap module, you can try:

$ drush pm-uninstall simple_sitemap

That should get your site to load again. Then export the database from your production site and import it in your local environment to see if you can duplicate the bug.

Often, problems like this are caused by applying database schema updates in your local environment and forgetting to do it again in production. It could also be caused by a code update, even to custom code if it home into this module, but the most likely explanation is that you just need to run drush updb on the server.

Also, this sort of error usually means that you are not deploying configuration when you deploy code.

Good luck!

Kaka Awira avatar
tr flag
I managed to install drush 10 and tried to clear the cache but the problem persisted as I still cannot clear cache with drush. What I did however that solved the problem is that I uninstalled the Simple XML Sitemap from my local development and then upload the site to cpanel. Thanks you gave me the hint to do what I did and the issue is gone.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.