Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when injecting legacy classes with an optional interface type hint #1120

Open
wagnert opened this issue Apr 29, 2019 · 0 comments
Open
Assignees
Labels

Comments

@wagnert
Copy link
Member

wagnert commented Apr 29, 2019

When trying to load an instance of a legacy class that has not been registered in the appserver.io DI container with an optional interface type hint like

    public function __construct(ChoiceListFactoryInterface $choiceListFactory = null)
    {
        $this->choiceListFactory = $choiceListFactory ?: new CachingFactoryDecorator(
            new PropertyAccessDecorator(
                new DefaultChoiceListFactory()
            )
        );
    }

the following exception occurs

[2019-04-29 20:58:40] - Tims-MacBook-Pro.local (error): AppserverIo\Appserver\DependencyInjectionContainer\NotFoundException {#21178
  #message: "DI error when try to inject dependencies for identifier "TechDivision\Project\Symfony\Bridge\Extension\Core\Type\ChoiceType""
  #code: 0
  #file: "/Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/DependencyInjectionContainer/Provider.php"
  #line: 581
  -previous: AppserverIo\Appserver\DependencyInjectionContainer\NotFoundException {#21186
    #message: "DI definition for identifier "Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface" is not available"
    #code: 0
    #file: "/Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/DependencyInjectionContainer/Provider.php"
    #line: 586
    trace: {
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/DependencyInjectionContainer/Provider.php:586 {
        ›     // throw an exception if no entry was found for **this** identifier
        ›     throw new NotFoundException(sprintf('DI definition for identifier "%s" is not available', $id));
        › }
      }
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/DependencyInjectionContainer/Provider.php:356 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/DependencyInjectionContainer/Provider.php:571 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Extension/DependencyInjection/DependencyInjectionExtension.php:65 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormRegistry.php:78 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormFactory.php:74 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormFactory.php:72 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormFactory.php:175 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormBuilder.php:60 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormBuilder.php:129 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormBuilder.php:269 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormBuilder.php:215 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Extension/Core/Type/CollectionType.php:40 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/ResolvedFormType.php:126 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormFactory.php:80 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormFactory.php:49 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormFactory.php:175 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormFactory.php:38 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Form.php:863 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Form_Subscriber_AccessControlSubscriber.php:106 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Form_Subscriber_AccessControlSubscriber.php:247 { …}
      TechDivision\Project\Form\Subscriber\AccessControlSubscriber->enforceAccessControl() {}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/event-dispatcher/EventDispatcher.php:212 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/event-dispatcher/EventDispatcher.php:44 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php:33 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Form.php:339 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Form.php:487 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormBuilder.php:226 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Actions_AbstractFormAction.php:223 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Actions_AbstractFormAction.php:1334 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Actions_AbstractFormAction.php:509 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Actions_AbstractFormAction.php:1961 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/appserver-io/routlt/src/AppserverIo/Routlt/DispatchAction.php:87 { …}
      /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/appserver-io/routlt/src/AppserverIo/Routlt/ControllerServlet.php:533 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/ServletEngine/ServletValve.php:57 { …}
      /Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/ServletEngine/RequestHandler.php:173 { …}
    }
  }
  trace: {
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/DependencyInjectionContainer/Provider.php:581 {
      › } catch (\Exception $e) {
      ›     throw new NotFoundException(sprintf('DI error when try to inject dependencies for identifier "%s"', $id), null, $e);
      › }
    }
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Extension/DependencyInjection/DependencyInjectionExtension.php:65 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormRegistry.php:78 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormFactory.php:74 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormFactory.php:72 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormFactory.php:175 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormBuilder.php:60 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormBuilder.php:129 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormBuilder.php:269 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormBuilder.php:215 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Extension/Core/Type/CollectionType.php:40 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/ResolvedFormType.php:126 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormFactory.php:80 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormFactory.php:49 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Symfony_Bridge_FormFactory.php:175 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormFactory.php:38 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Form.php:863 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Form_Subscriber_AccessControlSubscriber.php:106 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Form_Subscriber_AccessControlSubscriber.php:247 { …}
    TechDivision\Project\Form\Subscriber\AccessControlSubscriber->enforceAccessControl() {}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/event-dispatcher/EventDispatcher.php:212 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/event-dispatcher/EventDispatcher.php:44 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php:33 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Form.php:339 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/Form.php:487 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/symfony/form/FormBuilder.php:226 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Actions_AbstractFormAction.php:223 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Actions_AbstractFormAction.php:1334 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Actions_AbstractFormAction.php:509 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/var/tmp/localhost/td-project/cache/TechDivision_Project_Actions_AbstractFormAction.php:1961 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/appserver-io/routlt/src/AppserverIo/Routlt/DispatchAction.php:87 { …}
    /Users/wagnert/Workspace_Idea/techdivision/td-project/src/vendor/appserver-io/routlt/src/AppserverIo/Routlt/ControllerServlet.php:533 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/ServletEngine/ServletValve.php:57 { …}
    /Users/wagnert/Workspace_Idea/appserver-io/appserver/src/AppserverIo/Appserver/ServletEngine/RequestHandler.php:173 { …}
  }
}
@wagnert wagnert self-assigned this Apr 29, 2019
@wagnert wagnert added the bug label Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant