我正在开发symfony2项目,并且我得到了这个异常。任何人有什么想法造成它? 未找到带'Gmjob \ ExamBundle \ Entity \ Examination object not found'消息的异常'Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException'。在/数据/阿帕奇/ WWW/emploipublic-SF /供应商/ SENSIO /框架-额外包/ Sensio公司/包/ FrameworkExtraBundle /请求/ ParamConverter/DoctrineParamConverter.php:55 \ nStackSymfony Component HttpKernel Exception NotFoundHttpException:找不到对象
public function apply(Request $request, ConfigurationInterface $configuration)
{
$name = $configuration->getName();
$class = $configuration->getClass();
$options = $this->getOptions($configuration);
// find by identifier?
if (false === $object = $this->find($class, $request, $options, $name)) {
// find by criteria
if (false === $object = $this->findOneBy($class, $request, $options)) {
if ($configuration->isOptional()) {
$object = null;
} else {
throw new \LogicException('Unable to guess how to get a Doctrine instance from the request information.');
}
}
}
if (null === $object && false === $configuration->isOptional()) {
throw new NotFoundHttpException(sprintf('%s object not found.', $class)); // this is line 55
}
$request->attributes->set($name, $object);
return true;
}
这里是堆栈跟踪抛出异常:
[2014年9月16日16:56:03] [错误] [客户端217.89.107.38] PHP致命错误:未收集异常'Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException'带消息'Gmjob \ ExamBundle \ Entity \ Examination object not found。'在/data/apache/www/emploipublic-sf/vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter/DoctrineParamConverter.php:55\nStack迹:\ n
#0/data/apache/www/emploipublic-sf/vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter/ParamConverterManager.php(92):Sensio \ Bundle \ FrameworkExtraBundle \ Request \ ParamConverter \ DoctrineParamConverter-> (Object(Symfony \ Component \ HttpFoundation \ Request),Object(Sensio \ Bundle \ FrameworkExcelBundle \ Configuration \ ParamConverter))\ n
#1/data/apache/www/emploipublic-sf/vendor/sensio/framework -extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter/ParamConverterManager.php(48):Sensio \ Bundle \ FrameworkExtraBundle \ Request \ ParamConverter \ ParamConverterManager-> applyConverter(Object(Symfony \ Component \ HttpFoundation \ Request),Object(Sens in/data/apache/www/emploipublic-sf/vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle /请求/ ParamConverter/DoctrineParamConverter.php on line 55
我会认为这是因为你的'$ object'为空,'$ configuration-> isOptional();'方法返回false。 – Ohgodwhy 2014-09-25 06:29:14