framework: Receiving `ReflectionException: Method __PHP_Incomplete_Class::handle() does not exist` when queue job fires

i have an abstract class that extends Job. The job is queued and when it fires in production i get the error __PHP_Incomplete_Class::handle() does not exist. In all fairness handle doesn’t exist on my extended class.

Am I just doing something wrong?

abstract class MailingListBase extends Job implements ShouldQueue
{
    public function handle(MailChimp $mailChimp, 
                Mailer $mailer, MailChimpResponse $mailChimpResponse)
    {
        $this->mailChimp = $mailChimp;
        $this->mailer = $mailer;
        $this->mailChimpResponse = $mailChimpResponse;
        try {
            $this->process();
        } catch (Exception $e) {
            $data = $this->getData($e);
            $this->sendMail($data);
            $this->storeResponse($data);
        }
    }
}
class MailingListSubscribe extends MailingListBase
{

    protected $action = "subscribing";

    protected function process()
    {
        $this->mailChimp
            ->lists
            ->subscribe(
                $this->listId,
                [
                    'email' => $this->user->email
                ],
                [
                    'NAME' => $this->user->name,
                    'USERNAME' => $this->user->username
                ],
                'html',
                false
            );
    }
}
ReflectionException: Method __PHP_Incomplete_Class::handle() does not exist in /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php:1263

[2016-04-19 15:13:02] production.ERROR: ReflectionException: Method __PHP_Incomplete_Class::handle() does not exist in /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php:1263
Stack trace:
#0 /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php(1263): ReflectionMethod->__construct(Object(__PHP_Incomplete_Class), 'handle')
#1 /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php(1252): Illuminate\Container\Container->getCallReflector(Array)
#2 /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php(1239): Illuminate\Container\Container->getMethodDependencies(Array, Array)
#3 /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php(9754): Illuminate\Container\Container->call(Array)
#4 [internal function]: Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(__PHP_Incomplete_Class))
#5 /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php(9846): call_user_func(Object(Closure), Object(__PHP_Incomplete_Class))
#6 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(__PHP_Incomplete_Class))
#7 /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php(9828): call_user_func(Object(Closure), Object(__PHP_Incomplete_Class))
#8 /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php(9755): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#9 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(41): Illuminate\Bus\Dispatcher->dispatchNow(Object(__PHP_Incomplete_Class))
#10 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(129): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\BeanstalkdJob), Array)
#11 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/Jobs/BeanstalkdJob.php(53): Illuminate\Queue\Jobs\Job->resolveAndFire(Array)
#12 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(210): Illuminate\Queue\Jobs\BeanstalkdJob->fire()
#13 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(158): Illuminate\Queue\Worker->process('beanstalkd', Object(Illuminate\Queue\Jobs\BeanstalkdJob), '5', 0)
#14 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(111): Illuminate\Queue\Worker->pop('beanstalkd', 'default', 0, '10', '5')
#15 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(85): Illuminate\Queue\Worker->runNextJobForDaemon('beanstalkd', 'default', 0, '10', '5')
#16 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(103): Illuminate\Queue\Worker->daemon('beanstalkd', 'default', 0, 128, '10', '5')
#17 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(71): Illuminate\Queue\Console\WorkCommand->runWorker('beanstalkd', 'default', 0, 128, true)
#18 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#19 /home/forge/mysite.com/releases/20160415212843/bootstrap/cache/compiled.php(1240): call_user_func_array(Array, Array)
#20 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#21 /home/forge/mysite.com/releases/20160415212843/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /home/forge/mysite.com/releases/20160415212843/vendor/symfony/console/Application.php(791): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /home/forge/mysite.com/releases/20160415212843/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /home/forge/mysite.com/releases/20160415212843/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /home/forge/mysite.com/releases/20160415212843/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 {main}  
[2016-04-19 15:13:02] production.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: method_exists(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "MySite\Users\Jobs\MailingListSubscribe" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition  in /home/forge/mysite.com/releases/20160415212843/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:74
Stack trace:
#0 {main}  

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 8
  • Comments: 31 (6 by maintainers)

Most upvoted comments

I’ve got the same error on the production server. My case is, running two project in same server and using same beanstalk queue. I don’t know why, the job is running in the different project. The queue job of the first project is running in the second project, and obviously those file is not same, so QueueHandler can’t rebuild the Classes. I can’t replicate it in local, can’t debug it, no solution and still frustrated.

If you are using multiple projects and all these projects are using the same driver with same connection name then you may get this error. Because all of these projects - if not changed from “default” - will push to the same queue and when manually or 'supervisor’ly work this queue it will try to process ‘job A’ on ‘project B’ or vice versa.

To prevent this, just rename the “queue” key on queue.php/ connections / redis|beanstalk

Getting the same error. Why was this issue closed?

I was trying to use the same queue name on multiple projects on the same server. Live and learn 😃

Getting it here too. Seriously @GrahamCampbell you need to tell us the resolution before closing the ticket!

I met the same problem and found is case sensitive in namespace

READ !!! On the worker side all classes in the folder app/Jobs with controllers that the jobs references should also exists that you have created in the root app !! The Best practice is to copy the app folder from the main app to the worker app.

I had that same problem and it is now gone !

I just started running into this issue as well, only in production. When I deployed, all queues were empty, and it’s only new jobs that I see this happening for. I solved it by restarting both my queue workers in Forge.

I solved this problem with flushdb in redis

Had the same issue. My case was I had two versions of the project connected to the same database and the database was my queues driver. So one project was trying to handle the queue of the other version of the project while it didn’t have the job to “handle” it.

For everyone’s information, the __PHP_Incomplete_Class is created when you have serialized a class and then unserialized it at another time and PHP doesn’t know how to recreate it. For queues in laravel, this is why they have a specific SerializesModel trait.

This issue occurs when you have a class in your constructor (typically) signature that does not unserialize correctly. For me my signature was as follows:

public function __construct(array $work, User $user, Carbon $lastTimeRan)

When I changed the $lastTimeRan in my method signature from Carbon (which PHP didn’t know how to unserialize) to just an integer timestamp, the error went away. I am not sure this is the exact problem everyone is having, so this would make a create support forum ticket.

http://stackoverflow.com/questions/2010427/php-php-incomplete-class-object-with-my-session-data

I have the same issue, started 4 days ago.

Could be wrong but it seems that laravel doesn’t see this error as a “try” of the job even though I’ve set the tries to 3, it seems to be looping these jobs until I flush redis.