Not sure if it's just me but I'm getting the below fatal error when clearing cache with both drush 8.2.2 and drupal console 1.8.0
$ drush cr
PHP Fatal error: Uncaught Error: Class 'Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\FieldItemNormalizerImpostor' not found in /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php:270
Stack trace:
#0 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\Component\DependencyInjection\Container->createService(Array, 'serializer.norm...')
#1 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(480): Drupal\Component\DependencyInjection\Container->get('serializer.norm...', 1)
#2 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(508): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#3 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(230): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#4 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\Component\DependencyInjection\Container->createService(Array, in /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 270
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Uncaught Error: Class 'Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\FieldItemNormalizerImpostor' not
found in /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php:270
Stack trace:
#0 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
Drupal\Component\DependencyInjection\Container->createService(Array, 'serializer.norm...')
#1 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(480):
Drupal\Component\DependencyInjection\Container->get('serializer.norm...', 1)
#2 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(508):
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#3 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(230):
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#4 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
Drupal\Component\DependencyInjection\Container->createService(Array, in
/app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php, line 270
$ drupal cr all
PHP Fatal error: Uncaught Error: Class 'Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\FieldItemNormalizerImpostor' not found in /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php:270
Stack trace:
#0 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\Component\DependencyInjection\Container->createService(Array, 'serializer.norm...')
#1 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(480): Drupal\Component\DependencyInjection\Container->get('serializer.norm...', 1)
#2 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(508): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#3 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(230): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#4 /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\Component\DependencyInjection\Container->createService(Array, in /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 270
Fatal error: Uncaught Error: Class 'Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\FieldItemNormalizerImpostor' not found in /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 270
Error: Class 'Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\FieldItemNormalizerImpostor' not found in /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 270
Call Stack:
0.0036 359448 1. {main}() /app/vendor/drupal/console/bin/drupal:0
0.0062 378184 2. require('/app/vendor/drupal/console/bin/drupal.php') /app/vendor/drupal/console/bin/drupal:4
12.6682 53112312 3. Drupal\Console\Application->run() /app/vendor/drupal/console/bin/drupal.php:89
12.6830 53288608 4. Drupal\Console\Application->doRun() /app/vendor/symfony/console/Application.php:148
18.6623 58689872 5. Drupal\Console\Application->doRun() /app/vendor/drupal/console/src/Application.php:64
20.1211 75333976 6. Drupal\Console\Application->doRun() /app/vendor/drupal/console-core/src/Application.php:185
20.1255 75336400 7. Drupal\Console\Application->doRunCommand() /app/vendor/symfony/console/Application.php:255
I debugged a bit and reckon that Composer Classloader adds 'Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\FieldItemNormalizerImpostor' into its missingClasses
before Drupal calls addPsr4()
to add the container.namespaces into class loader. An interesting point is that clearing cache via admin UI doesn't cause the fatal error and JSON:API Extras still works with its normalizers and field enhancers.
I am using Composer version 1.8.4 2019-02-11 10:52:10
, Drush 8.2.2
, Drupal Console 1.8.0
, Drupal 8.6.12
, and JSON:API 8.x-2.4
. Is there any other requirement that I'm missing?
Comment | File | Size | Author |
---|---|---|---|
#20 | 3045087-fatal-error-with-impostor-normalizers-when-there-is-an-autowired-service.patch | 1.9 KB | j1mb0b |
| |||
#4 | error.txt | 7.96 KB | bander2 |
Comments
Comment #2
Wim LeersComment #3
jungleIt's happened on one of my sites.
Comment #4
bander2 CreditAttribution: bander2 as a volunteer commentedI got the same error when trying to install jsonapi_extras on a D8.7.1 site through the UI.
Comment #5
igarbla CreditAttribution: igarbla commentedSame here on a fresh installation.
Installing the module via
drupal moi jsonapi_extras
throws an error[ERROR] Class Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\FieldItemNormalizerImpostor does not exist
although the module seems to be installed, the settings doesn't appear.
Installing the module via the UI throws an error on screen
The website encountered an unexpected error. Please try again later.
If you try to navigate to the settings the same error appears, then if you clear caches via the UI, everything seems to work.Rebuilding cache via drupal/drush thows
PHP Fatal error: Uncaught Error: Class 'Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\FieldItemNormalizerImpostor' not found in /home/igarcia/Workshop/Sandbox/Drupal/drupal8-entity/web/core/lib/Drupal/Component/DependencyInjection/Container.php:277
Comment #6
esolitosIsn't this module already integrated in 8.7,x?
Comment #7
igarbla CreditAttribution: igarbla commentedThis is jsonapi_extras. The one integrated in 8.7.x is jsonapi.
Comment #8
christian.marx CreditAttribution: christian.marx commentedSolution:
- Create directory '/mdules/contrib/jsonapi/src/Normalizer/ImpostorFrom'
- Copy files from 'modul/contrib/jsonapi_extras/src-impostor-normalizers' to just created directory
Comment #9
psf_ CreditAttribution: psf_ at SDOS commentedComment #10
markhalliwellSo, this module is doing some weird stuff with namespaces (which doesn't follow PSR-4 btw):
https://git.drupalcode.org/project/jsonapi_extras/blob/8.x-3.x/src/Jsona...
Comment #11
psf_ CreditAttribution: psf_ at SDOS commentedA colleague found that the module webprofile break that. We remove it and all it's working now...
Comment #12
e0ipsoThanks for looping back onto this @psf_. Did she/he have confirmation of why it was interacting with the
webprofile
module?Comment #13
sonnyktMy sites don't have the module webprofiler enabled.
As per my debug, it may be something with Composer Classloader instead.
Comment #14
jncrucesHi,
I found the problem with WebProfiler helping @psf_.
But i don't think that the problem is related with WebProfiler... I think that the problem is an overload on the system. On our system the module that has produced the overload was Webprofiler because it was configured to store al profilling data in the database and the webprofiler table was very large.
I think that the method used to overwrite the services provided by JSONAPI using alterations of namespaces are not correct and produces this incongruences loading services. I know that a system overloaded is not correct but I think that any system can be overloaded sometimes because low server resources or not enough resources for a big amount of people using the site. A site overloaded must work... slow but must work.
All the services must be decorated normally without apply "impostor" namespaces on JSONAPI Extras. The solution is remove the enforce of JSONAPI namespace.
Greetings.
Comment #15
e0ipsoI agree. However that was introduced (temporarily) for good reason. We'd love to get a helping hand into reaching that eventual goal. Any chance you & your team can help out with it?
Comment #16
e0ipsoI've seen that this is triggered when some unrelated service uses
autowire: true
in the service definition.Comment #17
sonnyktMy sites have only one service enabled with
autowire: true
which is from permission_by_term module. I'll test further with the module disabled to confirm.Comment #18
e0ipsoThanks @sonnykt. It's good to see that the hypothesis seems to hold in your case.
Comment #19
j1mb0b CreditAttribution: j1mb0b as a volunteer commentedAfter reading Symfony docs I found:
https://symfony.com/doc/current/service_container/synthetic_services.html
Looking at this, the key part: "Services that are set at runtime are called synthetic services. This service has to be configured so the container knows the service exists during compilation (otherwise, services depending on kernel will get a "service does not exist" error).
Would it help to implement a synthetic service here?
Comment #20
j1mb0b CreditAttribution: j1mb0b as a volunteer commentedI found a workaround for my implementation, in the Container.php createService method there is an opportunity to require a file during the service definition creation.
See patch.
Comment #21
j1mb0b CreditAttribution: j1mb0b as a volunteer commentedComment #23
e0ipsoWorks as expected. Thanks!
Comment #24
patpluspun CreditAttribution: patpluspun commentedWorks for me when enabling webprofiler module. Thanks j1mb0b!
Comment #25
sonnyktConfirming that I no longer get the issue with this fix.