0

In my symfony2 application using doctrine2, I have an exception listener which logs any exception. If the exception is database related, if the entitymanager is closed, a new exception is raised in my exception listener, which is of course not good. i need to use another entity manager for logging.

So nowI'm trying to configure it and I get the following error :

The class 'AppBundle\Entity\User\User' was not found in the chain configured namespaces Payum\Core\Model, FOS\UserBundle\Model
500 Internal Server Error - MappingException

knowing that my current config is this :

doctrine:
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        default_entity_manager: default
        entity_managers:
            default:
                auto_mapping: true
            logging:
                mappings:
                    AppBundle: ~
                    PayumBundle: ~
                    FOSUserBundle: ~

What should I configure the mapping under logging? I've read I can't use auto_mapping a secondtime, though I'd like to have the same result. How can I do ?

Thanks a lot!

EDIT : the output of s doctrine:mapping:info --em=logging work

> php.exe D:\Divers\Programmation\Web\foodmeup.dev\app\console doctrine:mapping:info --em=logging
Found 52 mapped entities:
[OK]   AppBundle\Entity\Core\Journal
[OK]   AppBundle\Entity\Core\Media
[OK]   AppBundle\Entity\Core\NumberObject
[OK]   AppBundle\Entity\Core\ObjectCategory
[OK]   AppBundle\Entity\Core\Tag
[OK]   AppBundle\Entity\Core\Vote
[OK]   AppBundle\Entity\FoodAnalytics\Planning
[OK]   AppBundle\Entity\FoodAnalytics\Recipe
[OK]   AppBundle\Entity\FoodAnalytics\RecipeAsset
[OK]   AppBundle\Entity\FoodAnalytics\RecipeIngredient
[OK]   AppBundle\Entity\FoodAnalytics\RecipeStep
[OK]   AppBundle\Entity\FoodAnalytics\RecipeSubrecipe
[OK]   AppBundle\Entity\FoodAnalytics\Task
[OK]   AppBundle\Entity\FoodAnalytics\Team
[OK]   AppBundle\Entity\FoodAnalytics\Unit
[OK]   AppBundle\Entity\FoodAnalytics\UserAsset
[OK]   AppBundle\Entity\FoodAnalytics\UserIngredient
[OK]   AppBundle\Entity\FoodAnalytics\UserIngredientSupplier
[OK]   AppBundle\Entity\FoodAnalytics\UserRecipe
[OK]   AppBundle\Entity\FoodAnalytics\UserSupplier
[OK]   AppBundle\Entity\FoodAnalytics\Worker
[OK]   AppBundle\Entity\Job\Application
[OK]   AppBundle\Entity\Job\Availability
[OK]   AppBundle\Entity\Job\ContractType
[OK]   AppBundle\Entity\Job\Diploma
[OK]   AppBundle\Entity\Job\Experience
[OK]   AppBundle\Entity\Job\HierarchicalLevel
[OK]   AppBundle\Entity\Job\JobSeeker
[OK]   AppBundle\Entity\Job\Offer
[OK]   AppBundle\Entity\Job\Position
[OK]   AppBundle\Entity\Job\Skill
[OK]   AppBundle\Entity\Job\Training
[OK]   AppBundle\Entity\MarketPlace\Order
[OK]   AppBundle\Entity\MarketPlace\OrderGroup
[OK]   AppBundle\Entity\MarketPlace\OrderLine
[OK]   AppBundle\Entity\MarketPlace\OrderMessage
[OK]   AppBundle\Entity\MarketPlace\OrganizationProduct
[OK]   AppBundle\Entity\MarketPlace\Payment
[OK]   AppBundle\Entity\MarketPlace\PaymentToken
[OK]   AppBundle\Entity\MarketPlace\Product
[OK]   AppBundle\Entity\MarketPlace\Subscription
[OK]   AppBundle\Entity\Social\Comment
[OK]   AppBundle\Entity\Social\Post
[OK]   AppBundle\Entity\User\Associate
[OK]   AppBundle\Entity\User\Contact
[OK]   AppBundle\Entity\User\Group
[OK]   AppBundle\Entity\User\Notification
[OK]   AppBundle\Entity\User\Organization
[OK]   AppBundle\Entity\User\Role
[OK]   AppBundle\Entity\User\User
[OK]   AppBundle\Entity\User\UserCategory
[OK]   AppBundle\Entity\User\UserNotification

Process finished with exit code 0 at 18:08:38.
Execution time: 5 659 ms.
Sébastien
  • 5,263
  • 11
  • 55
  • 116
  • 1
    Not sure if you can use auto mapping for your default manager here. Try spelling out the mappings for both managers. And be sure your cache is cleared. – Cerad May 12 '15 at 14:28
  • it actually works if I remove the second entitymanager (logging) ans keep auto_mapping for the default one. Beyond that, is defining the mapping just listing all bundles names with '~' ? – Sébastien May 12 '15 at 14:31
  • Yep. It is unusual to have two managers with the exact same mappings. I would expect a logging manager to only have some logging entities. – Cerad May 12 '15 at 14:37
  • well, I certainly don't need every entity. But so far, I don't know what a good mapping configuration would be, and I don't know how to get rid of this error... – Sébastien May 12 '15 at 14:41
  • When are you getting this error? From the command line? Does app/console doctrine:mapping:info --em=logging work? – Cerad May 12 '15 at 14:53
  • I'm running this normally from my browser in dev environment. The command you gave me is working fine, I have 52 mapped entities. See the output in my edit. – Sébastien May 12 '15 at 16:09
  • So it's not a doctrine 2 config/mapping issue. I'm guessing you are trying to get something out of the closed manager. If you are certain the error is coming from the logging listener then maybe post some of it's code. – Cerad May 12 '15 at 16:14
  • well, just my home page won't load when this logging config is activated. This has to be a config issue – Sébastien May 12 '15 at 16:22
  • @Cerad , it was finally about the auto_mapping. Apparently you can use it only if you have only one entity manager... this might deserve an answer if you'd like – Sébastien May 13 '15 at 07:11
  • I never actually took the time to test my guess. I'd suggest just answering your own question for future reference. – Cerad May 13 '15 at 10:53

0 Answers0