laravel fail jobs中出现Exception: Job is incomplete class: {“__PHP_Incomplete_Class_Name
环境:Laravel10.x, php8.1
当新增一个jobs:ShoppOrderStatusNofify后。部署到正式服中,执行这个job时,有时成功,有时失败,会保存到fail_jobs中,有时重试失败的jobs,多试几次就成功,需要执行composer install, composer dump-autoload.php artisan queue:restart .php artisan queue:retry xxxxxxuidxxxdd. 有时成功,有时失败。
失败原因:项目中没有ShoppOrderStatusNofify这个class。需要composer install或composer dump-autoload。还要重启队列以生效。
失败解决,在服务器中已经执行的了多次composer install.且composer的 autoload_statics和autoload_classmap中已经有了这个class,说明这台服务器是正常的。
但是否还有其它服务器在执行job,而其它服务器中的项目代码并不是最新的,也没有执行composer install.
在aws上,果然发现了,之前的克隆服务器并没有停止或拉取新的代码,这就解释了,为什么重试失败的job几次,有时成功有时失败,失败是因为重试到克隆服务器去了,成功的是因为在正常的服务器上。
解决方式:确定克隆服务器不使用了,停止掉supervisorctl stop all. 停止克隆服务器。
Exception: Job is incomplete class: {“__PHP_Incomplete_Class_Name”:”App\\Jobs\\ShoppOrderStatusNofify”} in /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:117
Stack trace:
#0 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware()
#1 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\Queue\CallQueuedHandler->call()
#2 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(439): Illuminate\Queue\Jobs\Job->fire()
#3 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(389): Illuminate\Queue\Worker->process()
#4 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(176): Illuminate\Queue\Worker->runJob()
#5 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(138): Illuminate\Queue\Worker->daemon()
#6 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(121): Illuminate\Queue\Console\WorkCommand->runWorker()
#7 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#8 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#9 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#10 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#11 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call()
#12 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(208): Illuminate\Container\Container->call()
#13 /var/www/html/CFG-Backend/vendor/symfony/console/Command/Command.php(326): Illuminate\Console\Command->execute()
#14 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(178): Symfony\Component\Console\Command\Command->run()
#15 /var/www/html/CFG-Backend/vendor/symfony/console/Application.php(1081): Illuminate\Console\Command->run()
#16 /var/www/html/CFG-Backend/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand()
#17 /var/www/html/CFG-Backend/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun()
#18 /var/www/html/CFG-Backend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\Component\Console\Application->run()
#19 /var/www/html/CFG-Backend/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#20 {main}