JMSSecurityExtraBundle icon indicating copy to clipboard operation
JMSSecurityExtraBundle copied to clipboard

InactiveScopeException

Open MatthewReed opened this issue 10 years ago • 3 comments

Hello, after installing JMSSecurityExtraBundle I'm receiving the following exception message when I try to assetic:dump on console:

[Symfony\Component\DependencyInjection\Exception\InactiveScopeException] You cannot create a service ("request") of an inactive scope ("request").

More information: Symfony version: 2.3.13 JMSSecurityExtraBundle: bug found in both @stable and dev-master

AppKernel: ... new JMS\AopBundle\JMSAopBundle(), new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), new JMS\DiExtraBundle\JMSDiExtraBundle($this), ...

config.yml:

JMS Security Extra Configuration

jms_security_extra: # Whether you want to secure all services (true), or only secure specific # services (false); see also below secure_all_services: false

# Enabling this setting will add an additional special attribute "ROLE_IDDQD".
# Anybody with this attribute will effectively bypass all security checks.
enable_iddqd_attribute: false

# Enables expression language
expressions: true

# Allows you to disable some, or all built-in voters
voters:
    disable_authenticated: false
    disable_role:          false
    disable_acl:           false

# Allows you to specify access control rules for specific methods, such
# as controller actions
method_access_control: { }

No annotation inserted in code.

MatthewReed avatar May 07 '14 06:05 MatthewReed

please paste the stack trace of the exception (if it happens in the console, switch to verbose mode to see it)

stof avatar May 07 '14 09:05 stof

Exception trace: () at C:\xampp\htdocs\tgsupport\app\cache\dev\appDevDebugProjectContainer.php:3879 appDevDebugProjectContainer->getRequestService() at C:\xampp\htdocs\tgsupport\app\bootstrap.php.cache:1974 Symfony\Component\DependencyInjection\Container->get() at C:\xampp\htdocs\tgsupport\src\Technogym\MyWellnessBundle\DependencyInjection\MWAPIFactory.php:47 Technogym\MyWellnessBundle\DependencyInjection\MWAPIFactory->get() at C:\xampp\htdocs\tgsupport\app\cache\dev\appDevDebugProjectContainer.php:3610 appDevDebugProjectContainer->getMwApiTgsupportService() at C:\xampp\htdocs\tgsupport\app\bootstrap.php.cache:1974 Symfony\Component\DependencyInjection\Container->get() at C:\xampp\htdocs\tgsupport\src\Technogym\SecurityBundle\Security\User\MWUserProvider.php:29 Technogym\SecurityBundle\Security\User\MWUserProvider->__construct() at C:\xampp\htdocs\tgsupport\app\cache\dev\appDevDebugProjectContainer.php:3662 appDevDebugProjectContainer->getMwUserProviderService() at C:\xampp\htdocs\tgsupport\app\bootstrap.php.cache:1974 Symfony\Component\DependencyInjection\Container->get() at C:\xampp\htdocs\tgsupport\app\cache\dev\appDevDebugProjectContainer.php:7051 appDevDebugProjectContainer->getSecurity_Authentication_ManagerService() at C:\xampp\htdocs\tgsupport\app\bootstrap.php.cache:1974 Symfony\Component\DependencyInjection\Container->get() at C:\xampp\htdocs\tgsupport\app\cache\dev\appDevDebugProjectContainer.php:4269 appDevDebugProjectContainer->getSecurity_ContextService() at C:\xampp\htdocs\tgsupport\app\bootstrap.php.cache:1974 Symfony\Component\DependencyInjection\Container->get() at C:\xampp\htdocs\tgsupport\app\cache\dev\appDevDebugProjectContainer.php:6418 appDevDebugProjectContainer->getTwigService() at C:\xampp\htdocs\tgsupport\app\bootstrap.php.cache:1974 Symfony\Component\DependencyInjection\Container->get() at C:\xampp\htdocs\tgsupport\app\cache\dev\appDevDebugProjectContainer.php:748 appDevDebugProjectContainer->getAssetic_AssetManagerService() at C:\xampp\htdocs\tgsupport\app\bootstrap.php.cache:1974 Symfony\Component\DependencyInjection\Container->get() at C:\xampp\htdocs\tgsupport\vendor\symfony\assetic-bundle\Symfony\Bundle\AsseticBundle\Command\DumpCommand.php:50 Symfony\Bundle\AsseticBundle\Command\DumpCommand->initialize() at C:\xampp\htdocs\tgsupport\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:233 Symfony\Component\Console\Command\Command->run() at C:\xampp\htdocs\tgsupport\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:908 Symfony\Component\Console\Application->doRunCommand() at C:\xampp\htdocs\tgsupport\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:191 Symfony\Component\Console\Application->doRun() at C:\xampp\htdocs\tgsupport\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:96 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at C:\xampp\htdocs\tgsupport\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121 Symfony\Component\Console\Application->run() at C:\xampp\htdocs\tgsupport\app\console:27

As far as I can see such a bug is triggered by this piece of code

$this->container->get('request')->getRequestUri()

in a service factory get method, but I don't understand why it's appeared only after installing your bundle.

MatthewReed avatar May 07 '14 20:05 MatthewReed

well, the issue is in Technogym\MyWellnessBundle\DependencyInjection\MWAPIFactory, which does not handle the case of being outside the request handling (and this code seems called inside the constructor of your UserProvider, for which you have no guarantee that the instance will never be created outside request handling). the bug is in your code, not in JMSSecurityExtraBundle

stof avatar May 07 '14 23:05 stof