I am currently trying to perform a CRON job by executing a command in terminal. But it throws the following error.

```
PHP Fatal error:  Call to a member function has() on a non-object in /MyProject/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php on line 161

```

This is my code in the Command file.

```
namespace MyProject\UtilityBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

    class projectOngoingCommand extends Command
    {
        protected function configure()
        {
            $this
                ->setName('projectOngoingEstimation:submit')
                ->setDescription('Submit Ongoing Project Estimation')

                ;
        }

        protected function execute(InputInterface $input, OutputInterface $output)
        {

           ;
            $projectController= new \MyProject\ProjectBundle\Controller\DefaultController();  

             $msg = $projectController->updateMonthlyOngoingAllocation();

            $output->writeln($msg);
        }
    }

```

This is my code in the default controller.

```
// cron job code
    public function updateMonthlyOngoingAllocation() {

              $em = $this->getDoctrine()->getEntityManager();
        $project = $this->getDoctrine()->getRepository('MyProjectEntityBundle:Project')
                    ->getAllOngoingProjectList();
       return "hello";
      }

```

This method is called successfully using the command 

`sudo php app/console projectOngoingEstimation:submit`

But it throws the error in the very first line. i.e.

```
 $em = $this->getDoctrine()->getEntityManager();

```

when I tried to call the function from another Action method within the controller it works fine.