My Drupal 8 site is repeatedly showing the following error post 8.1.2 install::

Cannot redeclare class Doctrine\Common\Annotations\Annotation\Target in n< on line 31

Reverting to the previous version of Drupal 8 resolves this error. Obviously this isn't the ideal solution.

Comments

andystrong created an issue. See original summary.

cilefen’s picture

You did not include the entire error in the issue summary. We don't know which file is complaining on line 31.

cosmo.kramer’s picture

That was the full detail of the error. I will try and find more detail in the logs.

cilefen’s picture

Did you upgrade from a zip or gz download of core?

PLMK’s picture

Hello I'm also getting this error on a fresh install.

cilefen’s picture

Can you provide platform details like PHP version, memory allocated, web server, opcache, OS?

slechtic’s picture

Some problem.
My configuration:
Drupal 8.1.2
PHP 5.6.22
Gentoo 4.8.4 p1.6,
PHP memory limit 512MB
Zend OPcache
nginx - EDIT: I can't confirm on nginx yet,
Apache 2.2.31

cilefen’s picture

Can somebody please get the full error message into the issue summary? "n< on line 31" doesn't mean anything to me. There should be a filename. Of course, this could be a clue...

Is everybody on this issue using Nginx?

slechtic’s picture

My experience:
I try to clear cache, then I see the message like this:

Fatal error: Cannot redeclare class Doctrine\Common\Annotations\Annotation\Target in � on line 31
Fatal error: Cannot redeclare class Doctrine\Common\Annotations\Annotation\Target in �g� on line 31
Fatal error: Cannot redeclare class Doctrine\Common\Annotations\Annotation\Target in Pz� on line 31

and the site is down for a few seconds (approx. 30)

slechtic’s picture

Now I got:
Fatal error: Cannot redeclare class Doctrine\Common\Annotations\Annotation\Target in XXX/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php on line 31

cilefen’s picture

@slechtic You do not know the web server?

slechtic’s picture

@cilefen I know, Apache, I wanted to test on nginx but I can't confirm it.
When I disable opcache it works or when I invalidate cache for Target.php via opcache-gui, it works immediately.

cosmo.kramer’s picture

Error happened for me on local environment and Dreamhost VPS.

cilefen’s picture

How much RAM is allocated to opcache?

cosmo.kramer’s picture

I just tried updating from 8.1.1 to 8.1.3 and got the same error. This time my developer enabled show errors and the following came up:

The website encountered an unexpected error. Please try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "views_view" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 125 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
Drupal\Core\Entity\EntityRepository->loadEntityByUuid('views_view', 'views.order_history.order_history_view_page') (Line: 357)
Drupal\Core\Entity\EntityManager->loadEntityByUuid('views_view', 'views.order_history.order_history_view_page') (Line: 140)
menu_link_attributes_get_attributes(Object) (Line: 107)
menu_link_attributes_preprocess_menu(Array, 'menu', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('menu__modules_menu', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 468)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 90)
__TwigTemplate_32b8c256cf9e0802c308921662c9d65275eff772c9ac1417d912c68bf83dd230->block_content(Array, Array) (Line: 167)
Twig_Template->displayBlock('content', Array, Array) (Line: 79)
__TwigTemplate_32b8c256cf9e0802c308921662c9d65275eff772c9ac1417d912c68bf83dd230->doDisplay(Array, Array) (Line: 381)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 355)
Twig_Template->display(Array) (Line: 366)
Twig_Template->render(Array) (Line: 64)
twig_render_template('themes/seahub/templates/block/block--system-menu-block.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 468)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 68)
__TwigTemplate_cb6ffd1343be7cf9b7305057bfd9bb9af7799c2529133863f4be47db20be8e40->doDisplay(Array, Array) (Line: 381)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 355)
Twig_Template->display(Array) (Line: 366)
Twig_Template->render(Array) (Line: 64)
twig_render_template('themes/seahub/templates/layout/page.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 468)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 127)
__TwigTemplate_d7f1b870d11193cbc899b1fb28627fae59f11e639ef3ff709f472c19cc46973b->doDisplay(Array, Array) (Line: 381)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 355)
Twig_Template->display(Array) (Line: 366)
Twig_Template->render(Array) (Line: 64)
twig_render_template('themes/seahub/templates/layout/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
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: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
bjmagar1906’s picture

Problem seems to be with your system configuration. I tried Drupal 8.1.2 with both Apache and nginx Worked without any problem but i have php 7.

cosmo.kramer’s picture

Anything specific that I should be looking at re the configuration? My Dreamhost VPS in on PHP 5.6. Should I try 7?

cosmo.kramer’s picture

Classic zero support from the Drupal community :(

cilefen’s picture

I asked you a question two months ago but no reply. The community tried!

Forwardslash’s picture

I just ran into this problem upgrading a site to Drupal 8.1.8 on a Dreamhost VPS with Apache and PHP5.6. I'm not sure if it's the Dreamhost environment or PHP 5.6, but upgrading my PHP package to 7 fixed the error. Hope that helps.

Cheers!

jv

cilefen’s picture

It sounds as though opcache still stores files that were moved or similar. Is it possible that it works if you switch back to 5.6? This is on the theory that switching versions empties the opcache.

johnpicozzi’s picture

I was having the same problem... I switched to PHP 7 and still had the issue. I was able to fix it (at least at this point) by increase my php memory limit to 256M and shutting of XCache. I think XCache and OPCache may have been conflicting.

Seegras’s picture

I think we just had the same problem, drupal 8.6.10 on php7.2 via php-fpm on nginx (Ubuntu 18.04 LTS)

We had the above error, and also this one:

2019/03/26 11:03:09 [error] 21463#21463: *40 FastCGI sent in stderr: "PHP message: Uncaught PHP Exception Drupal\Component\Plugin\Exception\PluginNotFoundException: "The "language-user-admin" plugin does not exist." at /home/user/httpdocs/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php line 52" while reading response header from upstream, client: 192.168.1.1, server: webserver.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-www-data.sock:", host: "webserver.com"

We solved it by turning off opcache (and reinstalling plugins et.al. via composer and drush from the commandline).

Version: 8.1.2 » 8.1.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.1.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

Most people on this thread seem to have resolved the issue. @cosmo.kramer did you find a resolution for your site? If so can you post a comment with the resolution? Or if you are still seeing it, can you reply to cilefen's question in #14?

lendude’s picture

Status: Active » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative

Cleaning up old bugs.

Sounds like this was an OPCache problem for most people.

If this is still an issue feel free to add some steps to reproduce this on a clean Drupal install and reopen this.