Mautic Community Forums

Weird error If send email trigger execute: You cannot create a service ....

Hi,



If I want sent email to the list through campaign I get weird error:

Code:
[SymfonyComponentDependencyInjectionExceptionInactiveScopeException] You cannot create a service ("templating.helper.assets") of an inactive scope ("request").

Do you have idea Where is problem?

Thank you so much.

Hi,

If I want sent email to the list through campaign I get weird error:

[SymfonyComponentDependencyInjectionExceptionInactiveScopeException] You cannot create a service ("templating.helper.assets") of an inactive scope ("request").

Do you have idea Where is problem?

Thank you so much.

What theme do you use?

I use my own template, but I also tried Coffee and Nature template. Doesn’t work

Where did you get that error? Could you check Mautic logs and server logs if there is some additional information? For example in what file it failed?

I get it When I call “mautic:campaigns:trigger --batch-limit=100 --force”.
I find nothing in logs.
I google it and found several topics about this issue https://www.google.sk/search?output=search&sclient=psy-ab&q=You+cannot+create+a+service+(“templating.helper.assets”)+of+an+inactive+scope+(“request”).&btnG=&oq=&gs_l=&pbx=1

I found dirty hack.
If I removed condition in MauticCoreBundleFactoryMauticFactory in getTemplating(), sending works.

I mean these lines:

// if (defined('IN_MAUTIC_CONSOLE')) { //enter the request scope in order to be use the templating.helper.assets service $this->container->enterScope('request'); $this->container->set('request', new Request(), 'request'); // }

How are you triggering the command? That constant is defined within the CLI app/console script so the hack shouldn’t be necessary.

@mbabker I am triggering over the script https://gist.github.com/escopecz/9a1a0b10861941a457f4 without command.

I’ve added line bellow to @escopecz script and it works now. Thank you for your assist.

defined('IN_MAUTIC_CONSOLE') or define('IN_MAUTIC_CONSOLE', 1);

I updated the script. @kuzmany2 Thanks for providing the answer back to community!