ReflectionException does not exist afer upgrading to NC 29

After upgrading to NextCloud 29.0.16.1 I get an Internal Server error.

Logfile says:
{“reqId”:“aGYdu7SGzSj@Z1F3Kjr8GAAAAAM”,“level”:3,“time”:“2025-07-03T06:05:48+00:00”,“remoteAddr”:“92.64.238.53”,“user”:“–”,“app”:“index”,“method”:“GET”,“url”:“/index.php/204”,“message”:“Class "OCA\Files\Controller\AjaxController" does not exist”,“userAgent”:“Mozilla/5.0 (Android) Nextcloud-android/3.31.4”,“version”:“29.0.16.1”,“exception”:{“Exception”:“ReflectionException”,“Message”:“Class "OCA\Files\Controller\AjaxController" does not exist”,“Code”:-1,“Trace”:[{“file”:“/var/www/clients/client28039/web36109/bestanden/lib/private/Route/Router.php”,“line”:480,“function”:“__construct”,“class”:“ReflectionClass”,“type”:“->”,“args”:[“OCA\Files\Controller\AjaxController”]},{“file”:“/var/www/clients/client28039/web36109/bestanden/lib/private/Route/Router.php”,“line”:440,“function”:“getAttributeRoutes”,“class”:“OC\Route\Router”,“type”:“->”,“args”:[“files”]},{“file”:“/var/www/clients/client28039/web36109/bestanden/lib/private/Route/Router.php”,“line”:149,“function”:“loadAttributeRoutes”,“class”:“OC\Route\Router”,“type”:“->”,“args”:[“files”]},{“file”:“/var/www/clients/client28039/web36109/bestanden/lib/private/Route/Router.php”,“line”:290,“function”:“loadRoutes”,“class”:“OC\Route\Router”,“type”:“->”,“args”:},{“file”:“/var/www/clients/client28039/web36109/bestanden/lib/private/Route/Router.php”,“line”:324,“function”:“findMatchingRoute”,“class”:“OC\Route\Router”,“type”:“->”,“args”:[“/204”]},{“file”:“/var/www/clients/client28039/web36109/bestanden/lib/base.php”,“line”:1069,“function”:“match”,“class”:“OC\Route\Router”,“type”:“->”,“args”:[“/204”]},{“file”:“/var/www/clients/client28039/web36109/bestanden/index.php”,“line”:49,“function”:“handleRequest”,“class”:“OC”,“type”:“::”,“args”:}],“File”:“/var/www/clients/client28039/web36109/bestanden/lib/private/Route/Router.php”,“Line”:480,“message”:“Class "OCA\Files\Controller\AjaxController" does not exist”,“exception”:{},“CustomMessage”:“Class "OCA\Files\Controller\AjaxController" does not exist”}}

This situation was posted earlier (may 2024).
The solution does not seem to apply since the router.php looks quite different:

public function loadRoutes($app = null) {
if (is_string($app)) {
$app = \OC_App::cleanAppId($app);
}

	$requestedApp = $app;
	if ($this->loaded) {
		return;
	}
	$this->eventLogger->start('route:load:' . $requestedApp, 'Loading Routes for ' . $requestedApp);
	if (is_null($app)) {
		$this->loaded = true;
		$routingFiles = $this->getRoutingFiles();

		foreach (\OC_App::getEnabledApps() as $enabledApp) {
			$this->loadAttributeRoutes($enabledApp);
		}
	} else {
		if (isset($this->loadedApps[$app])) {
			return;
		}
		$appPath = \OC_App::getAppPath($app);
		$file = $appPath . '/appinfo/routes.php';
		if ($appPath !== false && file_exists($file)) {
			$routingFiles = [$app => $file];
		} else {
			$routingFiles = [];
		}

		if (in_array($app, \OC_App::getEnabledApps())) {
			$this->loadAttributeRoutes($app);
		}
	}

	foreach ($routingFiles as $app => $file) {
		if (!isset($this->loadedApps[$app])) {
			if (!\OC_App::isAppLoaded($app)) {
				// app MUST be loaded before app routes
				// try again next time loadRoutes() is called
				$this->loaded = false;
				continue;
			}
			$this->loadedApps[$app] = true;
			$this->useCollection($app);
			$this->requireRouteFile($file, $app);
			$collection = $this->getCollection($app);
			$this->root->addCollection($collection);

			// Also add the OCS collection
			$collection = $this->getCollection($app.'.ocs');
			$collection->addPrefix('/ocsapp');
			$this->root->addCollection($collection);
		}
	}

	if (!isset($this->loadedApps['core'])) {
		$this->loadedApps['core'] = true;
		$this->useCollection('root');
		$this->setupRoutes($this->getAttributeRoutes('core'), 'core');
		require __DIR__ . '/../../../core/routes.php';

		// Also add the OCS collection
		$collection = $this->getCollection('root.ocs');
		$collection->addPrefix('/ocsapp');
		$this->root->addCollection($collection);
	}
	if ($this->loaded) {
		$collection = $this->getCollection('ocs');
		$collection->addPrefix('/ocs');
		$this->root->addCollection($collection);
	}
	$this->eventLogger->end('route:load:' . $requestedApp);
}

Looks like a different version, which I do not dare to modyfy.

Is it safe to upgrade to NC30 and will it solve the issue?
Anything else I can do to fix this?

1 Like

No one will give a warranty on your setup.
Usually I prefer get recent versions of my software, than start repair instead of repairing an eol version and update afterwards.

How did you update precisely?

We seem to have overlooked the support template we can’t specifically provide any advice.

However, this points to an update issue of some sort. Did you do a manual update perhaps?

See fix(Router): Stop loading routes of disabled apps by provokateurin · Pull Request #44797 · nextcloud/server · GitHub for resolution.

I’m using Installatron, and to be onest: I might have skipped some minor updates.

What is the location of the .php-files. I have limmited acces and can’t find the files that are mentioned there.

apps/files/lib/Controller/AjaxController.php I believe

This error usually happens because the app or code references a class that was removed or renamed in Nextcloud 29. The OCA\Files\Controller\AjaxController no longer exists in NC 29. Upgrading to NC 30 might help as it could include fixes, but be sure to back up first. Meanwhile, check if all your apps are fully updated and compatible with NC 29. Disable any outdated third-party apps. If the problem persists, you may need to clear Nextcloud’s cache (occ maintenance:repair) or seek a patch from the app developer. Avoid manual core code changes unless experienced.

Problem solved!
Thanks for all help.

Perhaps you may tell us how you solved your problem making this thread to a more usefull one.

upgrading to NC 30 did not resolve the issue.
I managed to locate the files (AjaxController.php) and deleted them. That solved the isse.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.