MappingException in jackalope-doctrine-dbal 1.0alpha3

39 views
Skip to first unread message

Elias Asfaw-Kirby

unread,
Mar 27, 2013, 12:15:54 AM3/27/13
to jackal...@googlegroups.com
Hello,

 I hope this is the right group to ask this question.

 Has anybody gotten a MappingException when trying the sample code (at https://github.com/doctrine/phpcr-odm-documentation/blob/master/en/reference/introduction.rst) to insert a "MyDocument"

 On line 33:
       $documentManager->persist($doc);
I get the following stacktrace:

Fatal error: Uncaught exception 'Doctrine\ODM\PHPCR\Mapping\MappingException' with message 'No identifier/path specified for Document "Demo\MyDocument". Every Document must have an identifier/path.' in C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\Mapping\MappingException.php on line 135

Doctrine\ODM\PHPCR\Mapping\MappingException: No identifier/path specified for Document "Demo\MyDocument". Every Document must have an identifier/path. in C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\Mapping\MappingException.php on line 135

Call Stack:
    0.1266     336160   1. {main}() C:\Development\XYZCorp\temp\phpcr\src\create_content.php:0
    5.1318    6573432   2. Doctrine\ODM\PHPCR\DocumentManager->persist(???) C:\Development\XYZCorp\temp\phpcr\src\create_content.php:33
    5.1318    6573432   3. Doctrine\ODM\PHPCR\UnitOfWork->scheduleInsert(???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\DocumentManager.php:592
    5.1318    6573552   4. Doctrine\ODM\PHPCR\UnitOfWork->doScheduleInsert(???, ???, ???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\UnitOfWork.php:577
    5.1319    6573832   5. Doctrine\ODM\PHPCR\DocumentManager->getClassMetadata(???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\UnitOfWork.php:589
    5.1319    6573832   6. Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory->getMetadataFor(???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\DocumentManager.php:272
    5.1319    6573832   7. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor(???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory.php:87
    5.1635    6595848   8. Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory->loadMetadata(???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php:212
    5.1635    6595848   9. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata(???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory.php:102
    5.2452    6952768  10. Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory->doLoadMetadata(???, ???, ???, ???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php:302
    5.2560    6955920  11. Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory->validateRuntimeMetadata(???, ???) C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory.php:141
    5.2560    6955920  12. Doctrine\ODM\PHPCR\Mapping\ClassMetadata->validateIdentifier() C:\Development\XYZCorp\temp\phpcr\vendor\doctrine\phpcr-odm\lib\Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory.php:225


 My environment is Window 7, 64bit using WAMP server.
            "require": {
                "doctrine/dbal": ">=2.2.0,<2.4",
                "jackalope/jackalope": ">=1.0-alpha2,<1.1",
                "php": ">=5.3.2"

 FYI also, I used to the same exception on line 12:
    $rootDocument = $documentManager->find(null, '/');
Until I replaced that line with: 
    $rootDocument = $session->getNode("/");

Thanks for the assistance,

Eli

David Buchmann

unread,
Mar 27, 2013, 7:55:25 AM3/27/13
to Elias Asfaw-Kirby, jackal...@googlegroups.com
hi,

not really the right list, as you ask about doctrine phpcr-odm and not
jackalope :-) but lets finish the discussion here.

i guess the right list would be the symfony-cmf-dev list.

first, did you notice the doc is also rendered at doctrine?
http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/introduction.html#storing-documents

the exception tells you that there is no id for this document.

> My environment is Window 7, 64bit using WAMP server.
> "require": {
> "doctrine/dbal": ">=2.2.0,<2.4",
> "jackalope/jackalope": ">=1.0-alpha2,<1.1",
> "php": ">=5.3.2"

you should depend explicitly on jackalope/jackalope-doctrine-dbal if you
want that. otherwise you could suddenly have
jackalope/jackalope-jackrabbit instead.

> FYI also, I used to the same exception on line 12:
> $rootDocument = $documentManager->find(null, '/');
> Until I replaced that line with:
> $rootDocument = $session->getNode("/");

that is not the same. the session (assuming that is
PHPCR\SessionInterface) will give you a node. the Doctrine
DocumentManager will find you a document (when looking for '/' it will
be of class Generic)

are you saying you assign the PHPCR node as parent of your document and
then you get this exception? that would be weird, you should get an
exception that Jackalope\Node is not a mapped document.

before you can persist a document, you need to assign the nodename and
the parent document, which must be a managed document. alternatively you
can assign the id field, but that needs to be an absolute path and the
parent element must already exist.

cheers,david
--
Liip AG // Agile Web Development // T +41 26 422 25 11
CH-1700 Fribourg // PGP 0xA581808B // www.liip.ch

Elias Asfaw-Kirby

unread,
Mar 27, 2013, 11:14:52 AM3/27/13
to jackal...@googlegroups.com, Elias Asfaw-Kirby
Thanks David,

 I reposted after redoing the sample from scratch on the mailing list suggested on the doctrine-phpcr-odm site, which is the doctrine group... if anybody needs, please follow the thread there...

Eli
Reply all
Reply to author
Forward
0 new messages