Skip to content

Nextcloud 21 beta 1 Error: Call to a member function getContainer() on null #24711

Description

@AndyXheli

Error: Call to a member function getContainer() on null

Error: Undefined index: workflowengine at /var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php#368

{
  "reqId": "tkApzuW9IxJofzWJ1Bl2",
  "level": 3,
  "time": "2020-12-15T15:59:22+00:00",
  "remoteAddr": "10.211.55.2",
  "user": "axheli",
  "app": "no app in context",
  "method": "POST",
  "url": "/index.php/settings/apps/enable",
  "message": {
    "Exception": "Error",
    "Message": "Call to a member function getContainer() on null",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
        "line": 143,
        "function": "delegateContainerRegistrations",
        "class": "OC\\AppFramework\\Bootstrap\\RegistrationContext",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
        "line": 86,
        "function": "registerApps",
        "class": "OC\\AppFramework\\Bootstrap\\Coordinator",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Installer.php",
        "line": 144,
        "function": "runLazyRegistration",
        "class": "OC\\AppFramework\\Bootstrap\\Coordinator",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/settings/lib/Controller/AppSettingsController.php",
        "line": 448,
        "function": "installApp",
        "class": "OC\\Installer",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 218,
        "function": "enableApps",
        "class": "OCA\\Settings\\Controller\\AppSettingsController",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 127,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
        "line": 157,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Route/Router.php",
        "line": 301,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/base.php",
        "line": 1008,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 37,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php",
    "Line": 369,
    "CustomMessage": "Error during service alias registration of workflowengine: Call to a member function getContainer() on null"
  },
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
  "version": "21.0.0.8",
  "id": "5fd8eb1ac2eec"
}
{
  "reqId": "tkApzuW9IxJofzWJ1Bl2",
  "level": 3,
  "time": "2020-12-15T15:59:22+00:00",
  "remoteAddr": "10.211.55.2",
  "user": "axheli",
  "app": "PHP",
  "method": "POST",
  "url": "/index.php/settings/apps/enable",
  "message": {
    "Exception": "Error",
    "Message": "Undefined index: workflowengine at /var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php#368",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php",
        "line": 368,
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
        "line": 143,
        "function": "delegateContainerRegistrations",
        "class": "OC\\AppFramework\\Bootstrap\\RegistrationContext",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
        "line": 86,
        "function": "registerApps",
        "class": "OC\\AppFramework\\Bootstrap\\Coordinator",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Installer.php",
        "line": 144,
        "function": "runLazyRegistration",
        "class": "OC\\AppFramework\\Bootstrap\\Coordinator",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/settings/lib/Controller/AppSettingsController.php",
        "line": 448,
        "function": "installApp",
        "class": "OC\\Installer",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 218,
        "function": "enableApps",
        "class": "OCA\\Settings\\Controller\\AppSettingsController",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 127,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
        "line": 157,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Route/Router.php",
        "line": 301,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/base.php",
        "line": 1008,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 37,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Log/ErrorHandler.php",
    "Line": 91,
    "CustomMessage": "--"
  },
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
  "version": "21.0.0.8",
  "id": "5fd8eb1ac2f20"
}

Activity

  1. kesselb commented on Dec 15, 2020

    @kesselb
    Contributor
  2. dartcafe commented on Dec 28, 2020

    @dartcafe
    Contributor

    Still present with NC21 beta-3.
    Error occurs when enabling any app. In polls it seems, that the migration doesn't run properly then (preSchemaChange seems not to be executed). I can't confirm if this relates to this issue, but with NC20 migrations run as expected.

  3. AndyXheli commented on Jan 16, 2021

    @AndyXheli
    ContributorAuthor

    Still present with NC21 beta-6.

  4. szaimen commented on Feb 20, 2021

    @szaimen
    Contributor

    Also seeing this issue on 21.0.0 final

  5. szaimen commented on Feb 20, 2021

    @szaimen
    Contributor
  6. TomasTokaMrazek commented on Feb 21, 2021

    @TomasTokaMrazek

    Is there a known fix?

  7. ChristophWurst commented on Feb 22, 2021

    @ChristophWurst
    Member

    is there any other error logged before the one about the undefined index or the getContainer? I don't see how the code can take that path without any preceding error

  8. szaimen commented on Feb 22, 2021

    @szaimen
    Contributor

    I get this one for every app before the getContainer error:

    {
      "reqId": "QGjRhKM7q7d7EfmjYfQE",
      "level": 3,
      "time": "2021-02-20T23:44:17+01:00",
      "remoteAddr": "",
      "user": "--",
      "app": "PHP",
      "method": "",
      "url": "--",
      "message": {
        "Exception": "Error",
        "Message": "Undefined index: news at /var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php#421",
        "Code": 0,
        "Trace": [
          {
            "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/RegistrationContext.php",
            "line": 421,
            "function": "onError",
            "class": "OC\\Log\\ErrorHandler",
            "type": "::"
          },
          {
            "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
            "line": 143,
            "function": "delegateContainerRegistrations",
            "class": "OC\\AppFramework\\Bootstrap\\RegistrationContext",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
            "line": 86,
            "function": "registerApps",
            "class": "OC\\AppFramework\\Bootstrap\\Coordinator",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Installer.php",
            "line": 146,
            "function": "runLazyRegistration",
            "class": "OC\\AppFramework\\Bootstrap\\Coordinator",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/legacy/OC_App.php",
            "line": 431,
            "function": "installApp",
            "class": "OC\\Installer",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/core/Command/App/Install.php",
            "line": 84,
            "function": "enable",
            "class": "OC_App",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php",
            "line": 255,
            "function": "execute",
            "class": "OC\\Core\\Command\\App\\Install",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/symfony/console/Application.php",
            "line": 1009,
            "function": "run",
            "class": "Symfony\\Component\\Console\\Command\\Command",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/symfony/console/Application.php",
            "line": 273,
            "function": "doRunCommand",
            "class": "Symfony\\Component\\Console\\Application",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/3rdparty/symfony/console/Application.php",
            "line": 149,
            "function": "doRun",
            "class": "Symfony\\Component\\Console\\Application",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/lib/private/Console/Application.php",
            "line": 215,
            "function": "run",
            "class": "Symfony\\Component\\Console\\Application",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/console.php",
            "line": 100,
            "function": "run",
            "class": "OC\\Console\\Application",
            "type": "->"
          },
          {
            "file": "/var/www/nextcloud/occ",
            "line": 11,
            "args": [
              "/var/www/nextcloud/console.php"
            ],
            "function": "require_once"
          }
        ],
        "File": "/var/www/nextcloud/lib/private/Log/ErrorHandler.php",
        "Line": 92,
        "CustomMessage": "--"
      },
      "userAgent": "--",
      "version": "21.0.0.18",
      "id": "603394c4e7be7"
    }
  9. klou commented on Feb 24, 2021

    @klou

    I also have the same 2 (sets of) errors, except ...RegistrationContext.php#404

  10. amatteo78 commented on Feb 24, 2021

    @amatteo78

    on NC21 final I see it, have you found any fix ?

  11. ChristophWurst commented on Feb 24, 2021

    @ChristophWurst
    Member

    Thanks a lot for the log @szaimen. I think I understand it now. There is only one occurrence in the code where we create and write the application instance to the $apps variable. And if there's an error there we silently continue.

    Could someone apply this patch and try again?

    diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php
    index 06a17e5242b..d82424f542b 100644
    --- a/lib/private/AppFramework/Bootstrap/Coordinator.php
    +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php
    @@ -118,7 +118,10 @@ class Coordinator {
                                            /** @var IBootstrap|App $application */
                                            $apps[$appId] = $application = $this->serverContainer->query($applicationClassName);
                                    } catch (QueryException $e) {
    -                                       // Weird, but ok
    +                                       $this->logger->logException($e, [
    +                                               'message' => "Application class $applicationClassName can't be loaded: " . $e->getMessage(),
    +                                               'level' => ILogger::FATAL,
    +                                       ]);
                                            continue;
                                    }
                                    try {
  12. szaimen commented on Feb 24, 2021

    @szaimen
    Contributor

    I've applied the fix, disabled the news app, enabled it again but the same error messages appear again.
    Also unfortunately no new error message was logged, so I'm not sure if the patch works.
    BTW: when I enable the news app, all those messages get logged: (which seem to be related to the enable command)
    image

  13. ChristophWurst commented on Feb 24, 2021

    @ChristophWurst
    Member

    Hmm did you flush your opcache? Try restarting the web server.

  14. szaimen commented on Feb 24, 2021

    @szaimen
    Contributor

    Yes, I've cleared the cache (redis and apcu) and restarted the whole server. Still the same.

  15. ChristophWurst commented on Feb 24, 2021

    @ChristophWurst
    Member

    So it's always erroring at the exact same line. Try this

    diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php
    index d2dc365d835..988313f20e8 100644
    --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php
    +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php
    @@ -38,6 +38,7 @@ use OCP\Dashboard\IManager;
     use OCP\EventDispatcher\IEventDispatcher;
     use OCP\ILogger;
     use Throwable;
    +use function array_shift;
     
     class RegistrationContext {
     
    @@ -399,7 +400,7 @@ class RegistrationContext {
                            }
                    }
     
    -               foreach ($this->aliases as $registration) {
    +               while (($registration = array_shift($this->aliases)) !== null) {
                            try {
                                    $apps[$registration['appId']]
                                            ->getContainer()
    @@ -416,7 +417,7 @@ class RegistrationContext {
                            }
                    }
     
    -               foreach ($this->parameters as $registration) {
    +               while (($registration = array_shift($this->parameters)) !== null) {
                            try {
                                    $apps[$registration['appId']]
                                            ->getContainer()
  16. ChristophWurst commented on Feb 24, 2021

    @ChristophWurst
    Member

    Now that I think about it I'm very confident that this is actually the problem. Let me also open a PR …

  17. added and removed
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Feb 24, 2021
  18. added this to the Nextcloud 22 milestone on Feb 24, 2021
  19. ChristophWurst commented on Feb 24, 2021

    @ChristophWurst
    Member

    See #25786

  20. szaimen commented on Feb 24, 2021

    @szaimen
    Contributor

    I've applied the patch and can confirm that it works. Thank you!

  21. ChristophWurst commented on Feb 24, 2021

    @ChristophWurst
    Member

    finally 🎊

  22. nikp123 commented on Mar 21, 2021

    @nikp123

    For some reason it works when I put offending apps into the non-writable directory, but not it's in wapps

    (and yes the wapps dir has properly set up permissions)

  23. Rafael-Kiewning commented on Mar 23, 2021

    @Rafael-Kiewning

    Sorry, but I’m new on github. I have the same problem. I’m trying to execute the patch but I can’t. Access denied. For sure I’m making something wrong. Must I specify any thing for git to recognize the patch? Thanks in advance

  24. hobbsecky commented on Mar 29, 2021

    @hobbsecky

    I've applied the patch and can confirm that it works. Thank you!

    Same here. Thanks!

  25. hobbsecky commented on Mar 29, 2021

    @hobbsecky

    finally 🎊

    Thanks! Worked for me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions