# Uncaught Exception: The service "" has a dependency on a non-existent service ""

**URL:** <https://forum.shopware.com/t/uncaught-exception-the-service-has-a-dependency-on-a-non-existent-service/104290>\
**Category:** Shopware 6 (German)\
**Created:** [14. Juni 2024 um 10:17 UTC](https://forum.shopware.com/t/uncaught-exception-the-service-has-a-dependency-on-a-non-existent-service/104290 "2024-06-14T10:17:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.kipp](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@thomas.kipp](https://forum.shopware.com/u/thomas.kipp)\
**Post date:** [14. Juni 2024 um 10:17 UTC](https://forum.shopware.com/t/uncaught-exception-the-service-has-a-dependency-on-a-non-existent-service/104290/1 "2024-06-14T10:17:09Z")

</div>

Hallo, habe analog zu anderen Plugins in der service.xml in einen Subscriber eine Klasse eingebunden, bekomme aber die Errormeldung:

```auto
Uncaught Exception: The service "WtCustomerRegistration\Subscriber\CustomerRegistration" has a dependency on a non-existent service "WtCustomerRegistration\Service\Mailer".

```

Was läuft da schief?  
Hier ein Auszug aus der composer.json:

```auto
    "extra": {
        "shopware-plugin-class": "WtCustomerRegistration\\WtCustomerRegistration",
        "label": {
            "de-DE": "Product Registration Plugin",
            "en-GB": "Product Registration Plugin"
        }
    },

```

Hier die services.xml

```auto
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>

        <service id="WtCustomerRegistration\Subscriber\CustomerRegistration">
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
            <argument type="service" id="WtCustomerRegistration\Service\Mailer"/>
            <tag name="kernel.event_subscriber"/>
        </service>

    </services>
</container>

```

Hier die Mailler Klasse:

```auto
<?php

namespace WtCustomerRegistration\Service;

/**
 *
 */
class Mailer
{

}

```

Und hier der Subscriber:

```auto
<?php declare(strict_types=1);

namespace WtCustomerRegistration\Subscriber;

use JetBrains\PhpStorm\NoReturn;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use WtCustomerRegistration\Service\Mailer;

/**
 *
 */
class CustomerRegistration implements EventSubscriberInterface
{
    private SystemConfigService $systemConfigService;
    private Mailer $mailer;

    public function __construct(SystemConfigService $systemConfigService,Mailer $mailer)
    {
        $this->systemConfigService = $systemConfigService;
        $this->mailer=$mailer;
    }

    public static function getSubscribedEvents(): array
    {
        // Return the events to listen to as array like this: <event to listen to> => <method to execute>
        return [
            StorefrontRenderEvent::class => 'onStoreFrontLoaded',
        ];
    }

    #[NoReturn] public function onStoreFrontLoaded(StorefrontRenderEvent $event): void
    {
        // Do something
        // E.g. work with the loaded entities: $event->getEntities()
    }
}

```

Was läuft da schief?

---

<div class="post-metadata">

**Author:** ![thomas.kipp](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@thomas.kipp](https://forum.shopware.com/u/thomas.kipp)\
**Post date:** [14. Juni 2024 um 10:32 UTC](https://forum.shopware.com/t/uncaught-exception-the-service-has-a-dependency-on-a-non-existent-service/104290/2 "2024-06-14T10:32:49Z")

</div>

Ich bin selber drauf gekommen: Ich muss die Mailer Klasse in der services.xml gesondert registrieren. So sieht das dann aus:

```auto
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>

        <service id="WtCustomerRegistration\Subscriber\CustomerRegistration">
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
            <argument type="service" id="WtCustomerRegistration\Service\Mailer"/>
            <tag name="kernel.event_subscriber"/>
        </service>
        <service id="WtCustomerRegistration\Service\Mailer">
        </service>
    </services>
</container>

```

Wenn in der Mailer Klasse zusätzliche Klassen oder Interfaces verwendet werden, müssen die in dem soeben zugefügten Mailer Dienst integriert werden

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/2/9/29c7587ba660f00e4995d1743162782e5d6d8653.svg) [@system](https://forum.shopware.com/u/system)\
**Post date:** [14. Juli 2024 um 10:33 UTC](https://forum.shopware.com/t/uncaught-exception-the-service-has-a-dependency-on-a-non-existent-service/104290/3 "2024-07-14T10:33:39Z")

</div>

Dieses Thema wurde automatisch 30 Tage nach der letzten Antwort geschlossen. Es sind keine neuen Antworten mehr erlaubt.
