When I fire php artisan queue:work command , it throws following error
PHP Fatal error: Call to a member function beginTransaction() on null in /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 576
PHP Stack trace:
PHP 1. {main}() /var/www/html/push_admin/setupl/artisan:0
PHP 2. Illuminate\Foundation\Console\Kernel->handle() /var/www/html/push_admin/setupl/artisan:36
PHP 3. Symfony\Component\Console\Application->run() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107
PHP 4. Symfony\Component\Console\Application->doRun() /var/www/html/push_admin/setupl/vendor/symfony/console/Application.php:117
PHP 5. Symfony\Component\Console\Application->doRunCommand() /var/www/html/push_admin/setupl/vendor/symfony/console/Application.php:186
PHP 6. Illuminate\Console\Command->run() /var/www/html/push_admin/setupl/vendor/symfony/console/Application.php:794
PHP 7. Symfony\Component\Console\Command\Command->run() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Console/Command.php:155
PHP 8. Illuminate\Console\Command->execute() /var/www/html/push_admin/setupl/vendor/symfony/console/Command/Command.php:256
PHP 9. Illuminate\Container\Container->call() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Console/Command.php:169
PHP 10. call_user_func_array:{/var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Container/Container.php:507}() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Container/Container.php:507
PHP 11. Illuminate\Queue\Console\WorkCommand->fire() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Container/Container.php:507
PHP 12. Illuminate\Queue\Console\WorkCommand->runWorker() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:79
PHP 13. Illuminate\Queue\Worker->pop() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:126
PHP 14. Illuminate\Queue\Worker->getNextJob() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:149
PHP 15. Illuminate\Queue\DatabaseQueue->pop() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:180
PHP 16. Illuminate\Database\Connection->beginTransaction() /var/www/html/push_admin/setupl/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php:162
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to a member function beginTransaction() on null
Anybody have any idea about it? Please help!!!
Also posted question on stack overflow http://stackoverflow.com/questions/39615770/php-fatal-error-call-to-a-member-function-begintransaction-on-null-in-connect
Hello,
I'm also getting this same error.
[2016-11-12 20:18:45] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to a member function beginTransaction() on null' in C:\wamp\www\blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:611
Stack trace:
Can anybody please help me?
Thanks,
@sachinvrg , Have you configured queue properly as described over here:
https://github.com/jenssegers/laravel-mongodb#queues
I have found the issue with my project.
I had not followed the queue configuration of the package.
Just follow the proper instruction and it works very well.
The specific issue that it's complaining about is that it's trying to get the PDO on a database connection that doesn't have it.
The getPdo() method returns null in the case of the mongodb driver connection. You may have to avoid using the database queue driver if you use this package, or you can overload the beginTransaction method to simply do nothing.
override this in authcontroller protected function incrementLoginAttempts(Request $request){}
@janhartigan , where to overload beginTransaction method?
Having this issue on Laravel 5.8 (latest) when attempting to connect through API.
`Call to a member function beginTransaction() on null {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to a member function beginTransaction() on null at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:109)
[stacktrace]
@phillmorgan28 did you eventually resolve this?
Anyone solved this problem? i am not using queue.
This issue still persists. I've already configured my queue.php according here: Laravel MongoDB Queues
Already ran php artisan config:cache and this are the values for my queue.php
config('queue.connections.database')
[
"driver" => "mongodb",
"table" => "jobs",
"queue" => "default",
"retry_after" => 90,
]
config('queue.failed')
[
"driver" => "mongodb",
"database" => "mongodb",
"table" => "failed_jobs",
]
Any other fix for this?
This issue still persists. I've already configured my
queue.phpaccording here: Laravel MongoDB QueuesAlready ran
php artisan config:cacheand this are the values for myqueue.phpconfig('queue.connections.database')
[ "driver" => "mongodb", "table" => "jobs", "queue" => "default", "retry_after" => 90, ]config('queue.failed')
[ "driver" => "mongodb", "database" => "mongodb", "table" => "failed_jobs", ]Any other fix for this?
@paouriel can't recreate, check that you've correct mongodb settings, probably you're not even connecting to db.
@divine I managed to create a workaround for this. I've created a temporary command.
Here: Laravel MongoDB Transaction Fix
@divine I managed to create a workaround for this. I've created a temporary command.
Here: Laravel MongoDB Transaction Fix
This is really bad practice to modify vendor files. As I've said can't really recreate it.
Fork this library https://github.com/Smolevich/demo-mongo-application and add configuration as well as examples so it will be easy to recreate issues you're having.
Any solution for this headache issue ?
The specific issue that it's complaining about is that it's trying to get the
PDOon a database connection that doesn't have it.The
getPdo()method returnsnullin the case of themongodbdriver connection. You may have to avoid using the database queue driver if you use this package, or you can overload thebeginTransactionmethod to simply do nothing.
Explain more please
The problem still exists. @jenssegers, please reopen this issue.
The problem still exists. @jenssegers, please reopen this issue.
See https://github.com/jenssegers/laravel-mongodb/pull/1904
Thanks!
Most helpful comment
@sachinvrg , Have you configured queue properly as described over here:
https://github.com/jenssegers/laravel-mongodb#queues
I have found the issue with my project.
I had not followed the queue configuration of the package.
Just follow the proper instruction and it works very well.