I'm using Doctrine2 and JMS Serializer, but the serializer is throwing a weird error:
AnnotationException: [Semantical Error] The class "Doctrine\ORM\Mapping\PrePersist" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the class doc comment of "Doctrine\ORM\Mapping\PrePersist". If it is indeed no annotation, then you need to add @IgnoreAnnotation("ORM\PrePersist") to the class doc comment of method User\User::prePersist().
That happens when I try to serialize an entity object. These are the relevant bits of the entity class:
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
/**
* @ORM\Entity
* @ORM\Table(name="products", indexes={
* @ORM\Index(columns={"price"}),
* })
* @ORM\HasLifecycleCallbacks
*/
class Product
{
// ...
/**
* @ORM\PrePersist
*/
public function prePersist()
{
$this->createdAt = new \DateTime;
$this->updatedAt = $this->createdAt;
}
// ...
}
I opened Doctrine\ORM\Mapping\PrePersist
and it is annotated with @Annotation
. So the bug seems to be on JMS's side, not Doctrine2.
What can be causing this?
Note: The correct tag in this case would be 'jmsserializer', not 'jmsserializerbundle'. Someone please create it if appropriate and/or remove this note.