1

error is ServiceNotFoundException: The service "jms_serializer.metadata_driver" has a dependency on a non-existent service "doctrine".

my configure in composer.json:

"jms/serializer-bundle": "dev-master", "jms/di-extra-bundle": "dev-master"

what's wrong?

user1683012
  • 315
  • 1
  • 5
  • 14

1 Answers1

2

Are you aliasing the default object constructor to the DoctrineObjectConstructor? E.g.

jms_serializer.object_constructor:
    alias: jms_serializer.doctrine_object_constructor

If you are, it appears that the DoctrineObjectConstructor assumes the use of Doctrine's ORM solution, not an ODM solution like MongoDB. Another user commented on the use of the DoctrineObjectConstructor with MongoDB here.

In summary, you need to redefine the DoctrineObjectConstructor with a reference to doctrine_mongodb instead of doctrine, e.g.:

jms_serializer.doctrine_object_constructor:
    class:        %jms_serializer.doctrine_object_constructor.class%
    public:       false
    arguments:    ["@doctrine_mongodb", "@jms_serializer.unserialize_object_constructor"]

Even if the issue isn't explicitly related to the DoctrineObjectConstructor, you may find that the above solution can be translated to the service or object causing problems in your configuration.

Community
  • 1
  • 1
Sean Quinn
  • 2,131
  • 1
  • 18
  • 48
  • Thank you for so detail answer,but it can't not work also when it serializer an list data and ration conllection object,do you know what can i do to solve it? – user1683012 Sep 23 '13 at 19:44
  • It appears that the JMS serializer still doesn't automatically know how to serialize cursors (at least with MongoDB), so you need to perform an extra step and turn the cursor into an array by calling the `toArray()` method on it. See this question and answer for further details: http://stackoverflow.com/questions/15257769/doctrine2-persistentcollection-and-jms-serializer/17815096#17815096 as it might help your question about the list. – Sean Quinn Sep 23 '13 at 20:34
  • Yes,I use toArray(),the list data can show,but the relationship can't been serialize,the nginx says 502 bad way,and the apache also can not load,what's the problem with it? – user1683012 Sep 24 '13 at 01:37