# Cannot instantiate custom repository

**URL:** <https://forum.shopware.com/t/cannot-instantiate-custom-repository/61671>\
**Category:** Programming (EN)\
**Created:** [10. September 2019 um 13:16 UTC](https://forum.shopware.com/t/cannot-instantiate-custom-repository/61671 "2019-09-10T13:16:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivanb](https://avatars.discourse-cdn.com/v4/letter/i/958977/32.png) [@ivanb](https://forum.shopware.com/u/ivanb)\
**Post date:** [10. September 2019 um 13:16 UTC](https://forum.shopware.com/t/cannot-instantiate-custom-repository/61671/1 "2019-09-10T13:16:38Z")

</div>

Hello everyone

I tried to get the instance of custom\_entity repository by calling `**this-\>container-\>get('custom\_entity.repository')**` inside base class of example plugin from GitHub repository ([GitHub - shopware/swag-docs-custom-entity: Shopware Platform example plugin from the documentation.](https://github.com/shopware/swag-docs-custom-entity)).

When I run install command inside the development store following error occurred: **You have requested a non-existent service "custom\_entity.repository**". Migration is executed successfully.

Is it possible to get the instance of&nbsp;this repository inside the base plugin class?

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [10. September 2019 um 13:29 UTC](https://forum.shopware.com/t/cannot-instantiate-custom-repository/61671/2 "2019-09-10T13:29:42Z")

</div>

Hello Ivan,

in general it is possible to get the repository services from the container in your plugin base class.

But you try to get a repository which is provided by your plugin. The container is only build with installed and activated plugin.  
So in the request where you try to install/activate your plugin, the service is of course not in the container. It would be first available in the very next request.&nbsp;

Best regards from Schöppingen

![cool](http://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "cool")&nbsp;Michael Telgmann

---

<div class="post-metadata">

**Author:** ![ivanb](https://avatars.discourse-cdn.com/v4/letter/i/958977/32.png) [@ivanb](https://forum.shopware.com/u/ivanb)\
**Post date:** [10. September 2019 um 13:44 UTC](https://forum.shopware.com/t/cannot-instantiate-custom-repository/61671/3 "2019-09-10T13:44:41Z")

</div>

Hello Michael,

Thank You for your quick answer.
