Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8741147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:15:30+00:00 2026-06-13T11:15:30+00:00

I am trying to serialize entities for mobile digest. I have this Entity class:

  • 0

I am trying to serialize entities for mobile digest. I have this Entity class:

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Entity\User as BaseUser;

/**
 * xxx\xxx\Entity\User
 *
 * @ORM\Table()
 * @ORM\Entity()
 * @ORM\Entity(repositoryClass="xxx\xxx\Entity\UserRepository")
 */
class User extends BaseUser
{
    /**
     *
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var \Doctrine\Common\Collections\ArrayCollection
     *
     * @ORM\OneToMany(targetEntity="\xxx\xxx\Entity\Music", mappedBy="user")
     */
    protected $musics;

    /**
     * @var \Doctrine\Common\Collections\ArrayCollection
     *
     * @ORM\OneToMany(targetEntity="\xxx\xxx\Entity\Message", mappedBy="user")
     */
    protected $messages;

    /**
     * @var \Doctrine\Common\Collections\ArrayCollection
     *
     * @ORM\OneToMany(targetEntity="\xxx\xxx\Entity\Location", mappedBy="user")
     */
    protected $locations;

    public function __construct()
    {
        parent::__construct();
        $this->musics = new ArrayCollection();
        $this->messages = new ArrayCollection();
        $this->locations = new ArrayCollection();
    }
}

Now when I call this line in my DefaultController.php:

$user = $this->getUser();
$em = $this->getDoctrine()->getManager();

$array = $em->getRepository('xxxBundle:User')
    ->findLatest();

$serializer = $this->get('serializer');
$response = $serializer->serialize($array, 'json'); //THIS LINE THROWS EXCEPTION

I have use Doctrine\Common\Collections\ArrayCollection; in DefaultController.php, but it seems the error is coming from inside JMSSerializerBundle.

What have I tried thusfar

  • I have tried defining the Doctrine annotations to start with a \, but that didn’t help
  • I have cleared my cache a million times
  • I have searched for similar exceptions, but they all seem to be caused by a typo and I’ve checked for typos for the last 48 hours and I can’t find one.

The classes were autogenerated with app/console.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:15:31+00:00Added an answer on June 13, 2026 at 11:15 am

    Take a look at this issue on GitHub: https://github.com/schmittjoh/JMSSerializerBundle/issues/123

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I'm trying serialize a class containing this property: [NonSerialized] property System::Collections::ObjectModel::ReadOnlyCollection<String^>^ IgnoredWords I
I have been trying to serialize a pretty big object. This object uses dictionaries
I am trying to serialize my Report class info to an XML. At this
I have been trying to serialize a list that contains arrays and lists. I
I am trying to serialize/deserialize JSON in Android using GSON. I have two classes
I have some XML that I am trying serialize like so: string Value =
I'm trying to serialize a model using the great Protobuf-NET. I cannot use the
I have a problem when sending Entity Framework-generated entities with navigation properties over WCF.
I'm trying to serialize an interface. I know that this is impossible throught the
I'm trying to serialize a class Message from a java server and send them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.