Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problem with multiple entity managers in production environment
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
David Marín Carreño  
View profile  
 More options Oct 11 2012, 3:24 am
From: David Marín Carreño <dma...@sice.com>
Date: Thu, 11 Oct 2012 09:24:00 +0200
Subject: Problem with multiple entity managers in production environment

Hello all.

I'm having a problem in production environment while using two entity managers, with a "class not found" problem while Doctrine tries to get my custom User class.

I think that the problem can be related with this strange behaviour:

If I execute
php app/console doctrine:mapping:info
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

But if I execute:

php app/console doctrine:mapping:info --env=prod

[Exception]
You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for
errors.

Only if specify the actual entity manager I get my User class:

php app/console doctrine:mapping:info --env=prod --em=user_config_db
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

Does anyone have any clue?

--
David Marín Carreño
SICE

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Marín Carreño  
View profile  
 More options Oct 11 2012, 4:24 am
From: David Marín Carreño <dma...@sice.com>
Date: Thu, 11 Oct 2012 10:24:33 +0200
Local: Thurs, Oct 11 2012 4:24 am
Subject: Re: [Symfony2] Problem with multiple entity managers in production environment

I've found what seems to be a bug in Symfony: the default entity manager must be named "default" if you want it to work in Production environment.
After changing it, now it works flawlessly.

El 11/10/2012 9:24, David Marín Carreño escribió:
Hello all.

I'm having a problem in production environment while using two entity managers, with a "class not found" problem while Doctrine tries to get my custom User class.

I think that the problem can be related with this strange behaviour:

If I execute
php app/console doctrine:mapping:info
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

But if I execute:

php app/console doctrine:mapping:info --env=prod

[Exception]
You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for
errors.

Only if specify the actual entity manager I get my User class:

php app/console doctrine:mapping:info --env=prod --em=user_config_db
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

Does anyone have any clue?

--
David Marín Carreño
SICE

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2@googlegroups.com<mailto:symfony2@googlegroups.com>
To unsubscribe from this group, send email to
symfony2+unsubscribe@googlegroups.com<mailto:symfony2+unsubscribe@googlegro ups.com>
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mr. Tool  
View profile  
 More options Oct 11 2012, 10:19 am
From: "Mr. Tool" <treml.mar...@gmail.com>
Date: Thu, 11 Oct 2012 07:19:18 -0700 (PDT)
Local: Thurs, Oct 11 2012 10:19 am
Subject: Re: [Symfony2] Problem with multiple entity managers in production environment

Hello David,

I'm also using multiple entity managers in my symfony2.1 application.

With following configuration everything works great also in production:

doctrine:
    dbal:
        default_connection: core
        connections:
            core:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name_core%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8

            other:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name_promotion%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8

    orm:
        default_entity_manager:   core
        entity_managers:
            core:
                connection: core
                mappings:
                    CoreBundle: ~

            other:
                connection: other
                mappings:
                    DataBundle: ~

The main problem on multiple entity managers is that you had to define
which bundle what entity manger should manage for you, so the default
auto_mapping want work anymore.
As second be sure you clear your cache of the dev an prod environment (if i
change something in my configuration and clear it everytime i got less
nasty moments)
And the third, be sure you set in the orm and dbal config the default
entity_manager

best regards,
Treml Martin

Am Donnerstag, 11. Oktober 2012 10:24:42 UTC+2 schrieb David Marín:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Marín Carreño  
View profile  
 More options Oct 11 2012, 10:51 am
From: David Marín Carreño <dma...@sice.com>
Date: Thu, 11 Oct 2012 16:51:17 +0200
Local: Thurs, Oct 11 2012 10:51 am
Subject: Re: [Symfony2] Problem with multiple entity managers in production environment

Hello. You are right: I've realized that the problem was also related to my security configuration, because whenever I disabled user authentication I had no problems.

As a matter of fact, I had a problem even in development environment if the User entity was not managed by default entity manager...

This is my security.yml:

security:
    encoders:
        MyFirm\UserManagerBundle\Entity\User:
            id: myfirm_usermanager.password_encoder
        Symfony\Component\Security\Core\User\User: plaintext

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        user_db:
            entity:
                class: MyFirm\UserManagerBundle\Entity\User
                property: username

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern:  ^/(es|en)/login$
            security: false

        secured_area:
            pattern:    ^/
            anonymous: ~
            form_login:
                check_path: /login_check
                login_path: /login
            logout:
                path:   /logout
                target: /
            #anonymous: ~
            #http_basic:
            #    realm: "Secured Demo Area"

    access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/i18n/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/, roles: ROLE_USER }
        #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        #- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }

El 11/10/2012 16:19, Mr. Tool escribió:
Hello David,

I'm also using multiple entity managers in my symfony2.1 application.

With following configuration everything works great also in production:

doctrine:
    dbal:
        default_connection: core
        connections:
            core:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name_core%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8

            other:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name_promotion%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8

    orm:
        default_entity_manager:   core
        entity_managers:
            core:
                connection: core
                mappings:
                    CoreBundle: ~

            other:
                connection: other
                mappings:
                    DataBundle: ~

The main problem on multiple entity managers is that you had to define which bundle what entity manger should manage for you, so the default auto_mapping want work anymore.
As second be sure you clear your cache of the dev an prod environment (if i change something in my configuration and clear it everytime i got less nasty moments)
And the third, be sure you set in the orm and dbal config the default entity_manager

best regards,
Treml Martin

Am Donnerstag, 11. Oktober 2012 10:24:42 UTC+2 schrieb David Marín:
I've found what seems to be a bug in Symfony: the default entity manager must be named "default" if you want it to work in Production environment.
After changing it, now it works flawlessly.

El 11/10/2012 9:24, David Marín Carreño escribió:
Hello all.

I'm having a problem in production environment while using two entity managers, with a "class not found" problem while Doctrine tries to get my custom User class.

I think that the problem can be related with this strange behaviour:

If I execute
php app/console doctrine:mapping:info
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

But if I execute:

php app/console doctrine:mapping:info --env=prod

[Exception]
You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for
errors.

Only if specify the actual entity manager I get my User class:

php app/console doctrine:mapping:info --env=prod --em=user_config_db
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

Does anyone have any clue?

--
David Marín Carreño
SICE

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com<http://symfony-project.com>

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to sym...@googlegroups.com<javascript:>
To unsubscribe from this group, send email to
symfony2+u...@googlegroups.com<javascript:>
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2@googlegroups.com<mailto:symfony2@googlegroups.com>
To unsubscribe from this group, send email to
symfony2+unsubscribe@googlegroups.com<mailto:symfony2+unsubscribe@googlegro ups.com>
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en

--
David Marín Carreño
SICE
Dirección Técnica.
Dpto. de Software Interurbano.
Tfno 91 623 23 36
E-mail: dma...@sice.com<mailto:dma...@sice.com>

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mr. Tool  
View profile  
 More options Oct 11 2012, 11:01 am
From: "Mr. Tool" <treml.mar...@gmail.com>
Date: Thu, 11 Oct 2012 08:01:05 -0700 (PDT)
Local: Thurs, Oct 11 2012 11:01 am
Subject: Re: [Symfony2] Problem with multiple entity managers in production environment

I think this is because the User Provider uses the default entity manger.

So you had to overwrite you UserProvider and set the entity manager to the
on you need.
There are some Tutorials for custom user providers on symfony.com inside
the book.

regards

Am Donnerstag, 11. Oktober 2012 16:51:35 UTC+2 schrieb David Marín:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Marín Carreño  
View profile  
 More options Oct 11 2012, 11:10 am
From: David Marín Carreño <dma...@sice.com>
Date: Thu, 11 Oct 2012 17:10:06 +0200
Local: Thurs, Oct 11 2012 11:10 am
Subject: Re: [Symfony2] Problem with multiple entity managers in production environment

El 11/10/2012 17:01, Mr. Tool escribió:
I think this is because the User Provider uses the default entity manger.

I think that User Provider uses the default entity manager in development environment.
In production environment, it seems that it uses the entity manager named "default".

So you had to overwrite you UserProvider and set the entity manager to the on you need.
There are some Tutorials for custom user providers on symfony.com inside the book.
Yes, in development env it worked flawlessly. In production, I can do it only if the entity manager is called "default".

regards

Am Donnerstag, 11. Oktober 2012 16:51:35 UTC+2 schrieb David Marín:
Hello. You are right: I've realized that the problem was also related to my security configuration, because whenever I disabled user authentication I had no problems.

As a matter of fact, I had a problem even in development environment if the User entity was not managed by default entity manager...

This is my security.yml:

security:
    encoders:
        MyFirm\UserManagerBundle\Entity\User:
            id: myfirm_usermanager.password_encoder
        Symfony\Component\Security\Core\User\User: plaintext

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        user_db:
            entity:
                class: MyFirm\UserManagerBundle\Entity\User
                property: username

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern:  ^/(es|en)/login$
            security: false

        secured_area:
            pattern:    ^/
            anonymous: ~
            form_login:
                check_path: /login_check
                login_path: /login
            logout:
                path:   /logout
                target: /
            #anonymous: ~
            #http_basic:
            #    realm: "Secured Demo Area"

    access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/i18n/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/, roles: ROLE_USER }
        #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        #- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }

El 11/10/2012 16:19, Mr. Tool escribió:
Hello David,

I'm also using multiple entity managers in my symfony2.1 application.

With following configuration everything works great also in production:

doctrine:
    dbal:
        default_connection: core
        connections:
            core:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name_core%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8

            other:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name_promotion%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8

    orm:
        default_entity_manager:   core
        entity_managers:
            core:
                connection: core
                mappings:
                    CoreBundle: ~

            other:
                connection: other
                mappings:
                    DataBundle: ~

The main problem on multiple entity managers is that you had to define which bundle what entity manger should manage for you, so the default auto_mapping want work anymore.
As second be sure you clear your cache of the dev an prod environment (if i change something in my configuration and clear it everytime i got less nasty moments)
And the third, be sure you set in the orm and dbal config the default entity_manager

best regards,
Treml Martin

Am Donnerstag, 11. Oktober 2012 10:24:42 UTC+2 schrieb David Marín:
I've found what seems to be a bug in Symfony: the default entity manager must be named "default" if you want it to work in Production environment.
After changing it, now it works flawlessly.

El 11/10/2012 9:24, David Marín Carreño escribió:
Hello all.

I'm having a problem in production environment while using two entity managers, with a "class not found" problem while Doctrine tries to get my custom User class.

I think that the problem can be related with this strange behaviour:

If I execute
php app/console doctrine:mapping:info
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

But if I execute:

php app/console doctrine:mapping:info --env=prod

[Exception]
You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for
errors.

Only if specify the actual entity manager I get my User class:

php app/console doctrine:mapping:info --env=prod --em=user_config_db
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

Does anyone have any clue?

--
David Marín Carreño
SICE

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com<http://symfony-project.com>

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to sym...@googlegroups.com
To unsubscribe from this group, send email to
symfony2+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com<http://symfony-project.com>

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to sym...@googlegroups.com<javascript:>
To unsubscribe from this group, send email to
symfony2+u...@googlegroups.com<javascript:>
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en

--
David Marín Carreño
SICE
Dirección Técnica.
Dpto. de Software Interurbano.
Tfno 91 623 23 36
E-mail: dma...@sice.com<javascript:>

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2@googlegroups.com<mailto:symfony2@googlegroups.com>
To unsubscribe from this group, send email to
symfony2+unsubscribe@googlegroups.com<mailto:symfony2+unsubscribe@googlegro ups.com>
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en

--
David Marín Carreño
SICE
Dirección Técnica.
Dpto. de Software Interurbano.
Tfno 91 623 23 36
E-mail: dma...@sice.com<mailto:dma...@sice.com>

________________________________
Este mensaje y cualquier fichero anexo está
...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mr. Tool  
View profile  
 More options Oct 11 2012, 11:25 am
From: "Mr. Tool" <treml.mar...@gmail.com>
Date: Thu, 11 Oct 2012 08:25:36 -0700 (PDT)
Local: Thurs, Oct 11 2012 11:25 am
Subject: Re: [Symfony2] Problem with multiple entity managers in production environment

Be sure you are using the right config and clearing cache before using prod
environment.
Also clear metadata cache of doctrine.

My entity manager is called core and also works in production environment
so i think its miss configuration or cache problem.

Could you post your doctrine configuration!?

Am Donnerstag, 11. Oktober 2012 17:10:17 UTC+2 schrieb David Marín:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Marín Carreño  
View profile  
 More options Oct 12 2012, 4:20 am
From: David Marín Carreño <dav...@gmail.com>
Date: Fri, 12 Oct 2012 01:20:24 -0700 (PDT)
Local: Fri, Oct 12 2012 4:20 am
Subject: Re: [Symfony2] Problem with multiple entity managers in production environment

El jueves, 11 de octubre de 2012 17:25:36 UTC+2, Mr. Tool escribió:

> Be sure you are using the right config and clearing cache before using
> prod environment.

I'm totally sure of that. And I have repeated it several times. I have even
renamed the default entity manager to "core", trying to mimic your
configuration, with no luck.

> Also clear metadata cache of doctrine.

I think that the metadata cache is kept in web server memory through APC,
and it is not used when using php app/console. Am I right?

The MappingException for class 'MyFirm\UserManagerBundle\Entity\User'  is
reproduced while trying to make a php app/console cache:warmup after a
successful cache:clear.

> My entity manager is called core and also works in production environment
> so i think its miss configuration or cache problem.

Perhaps the problem is related with the custom password encoder I am also
using. Do you have a custom password encoder?

> Could you post your doctrine configuration!?

I can, but not today: it's holliday in Spain and I have access to the code
only from the office. On next Monday I'll send it.

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Marín Carreño  
View profile  
 More options Oct 15 2012, 2:59 am
From: David Marín Carreño <dma...@sice.com>
Date: Mon, 15 Oct 2012 08:59:23 +0200
Local: Mon, Oct 15 2012 2:59 am
Subject: Re: [Symfony2] Problem with multiple entity managers in production environment

Here is my full doctrine configuration in config.yml:

# Doctrine Configuration
doctrine:
    dbal:
        default_connection: event_db
        connections:
            event_db:
                driver:   %event_database_driver%
                host:     %event_database_host%
                port:     %event_database_port%
                dbname:   %event_database_name%
                user:     %event_database_user%
                password: %event_database_password%
                charset:  UTF8
            user_config_db:
                driver:   %user_config_database_driver%
                host:     %user_config_database_host%
                port:     %user_config_database_port%
                dbname:   %user_config_database_name%
                user:     %user_config_database_user%
                password: %user_config_database_password%
                charset:  UTF8
    orm:
        # Here we must set the db in which users info is kept
        default_entity_manager: default
        auto_generate_proxy_classes: %kernel.debug%
        entity_managers:
            event_db:
                connection:   event_db
                mappings:
                    MyFirmEventManagerBundle: ~
            default:
                connection:   user_config_db
                mappings:
                    MyFirmUserManagerBundle: ~

El 12/10/2012 10:20, David Marín Carreño escribió:
El jueves, 11 de octubre de 2012 17:25:36 UTC+2, Mr. Tool escribió:
Be sure you are using the right config and clearing cache before using prod environment.

I'm totally sure of that. And I have repeated it several times. I have even renamed the default entity manager to "core", trying to mimic your configuration, with no luck.

Also clear metadata cache of doctrine.

I think that the metadata cache is kept in web server memory through APC, and it is not used when using php app/console. Am I right?

The MappingException for class 'MyFirm\UserManagerBundle\Entity\User'  is reproduced while trying to make a php app/console cache:warmup after a successful cache:clear.

My entity manager is called core and also works in production environment so i think its miss configuration or cache problem.

Perhaps the problem is related with the custom password encoder I am also using. Do you have a custom password encoder?

Could you post your doctrine configuration!?

I can, but not today: it's holliday in Spain and I have access to the code only from the office. On next Monday I'll send it.

Am Donnerstag, 11. Oktober 2012 17:10:17 UTC+2 schrieb David Marín:
El 11/10/2012 17:01, Mr. Tool escribió:
I think this is because the User Provider uses the default entity manger.

I think that User Provider uses the default entity manager in development environment.
In production environment, it seems that it uses the entity manager named "default".

So you had to overwrite you UserProvider and set the entity manager to the on you need.
There are some Tutorials for custom user providers on symfony.com<http://symfony.com> inside the book.
Yes, in development env it worked flawlessly. In production, I can do it only if the entity manager is called "default".

regards

Am Donnerstag, 11. Oktober 2012 16:51:35 UTC+2 schrieb David Marín:
Hello. You are right: I've realized that the problem was also related to my security configuration, because whenever I disabled user authentication I had no problems.

As a matter of fact, I had a problem even in development environment if the User entity was not managed by default entity manager...

This is my security.yml:

security:
    encoders:
        MyFirm\UserManagerBundle\Entity\User:
            id: myfirm_usermanager.password_encoder
        Symfony\Component\Security\Core\User\User: plaintext

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        user_db:
            entity:
                class: MyFirm\UserManagerBundle\Entity\User
                property: username

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern:  ^/(es|en)/login$
            security: false

        secured_area:
            pattern:    ^/
            anonymous: ~
            form_login:
                check_path: /login_check
                login_path: /login
            logout:
                path:   /logout
                target: /
            #anonymous: ~
            #http_basic:
            #    realm: "Secured Demo Area"

    access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/i18n/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/, roles: ROLE_USER }
        #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        #- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }

El 11/10/2012 16:19, Mr. Tool escribió:
Hello David,

I'm also using multiple entity managers in my symfony2.1 application.

With following configuration everything works great also in production:

doctrine:
    dbal:
        default_connection: core
        connections:
            core:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name_core%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8

            other:
                driver:   %database_driver%
                host:     %database_host%
                port:     %database_port%
                dbname:   %database_name_promotion%
                user:     %database_user%
                password: %database_password%
                charset:  UTF8

    orm:
        default_entity_manager:   core
        entity_managers:
            core:
                connection: core
                mappings:
                    CoreBundle: ~

            other:
                connection: other
                mappings:
                    DataBundle: ~

The main problem on multiple entity managers is that you had to define which bundle what entity manger should manage for you, so the default auto_mapping want work anymore.
As second be sure you clear your cache of the dev an prod environment (if i change something in my configuration and clear it everytime i got less nasty moments)
And the third, be sure you set in the orm and dbal config the default entity_manager

best regards,
Treml Martin

Am Donnerstag, 11. Oktober 2012 10:24:42 UTC+2 schrieb David Marín:
I've found what seems to be a bug in Symfony: the default entity manager must be named "default" if you want it to work in Production environment.
After changing it, now it works flawlessly.

El 11/10/2012 9:24, David Marín Carreño escribió:
Hello all.

I'm having a problem in production environment while using two entity managers, with a "class not found" problem while Doctrine tries to get my custom User class.

I think that the problem can be related with this strange behaviour:

If I execute
php app/console doctrine:mapping:info
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

But if I execute:

php app/console doctrine:mapping:info --env=prod

[Exception]
You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for
errors.

Only if specify the actual entity manager I get my User class:

php app/console doctrine:mapping:info --env=prod --em=user_config_db
Found 1 mapped entities:
[OK]   MyFirm\UserManagerBundle\Entity\User

Does anyone have any clue?

--
David Marín Carreño
SICE

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not necessarily represent the opinion of this Company. If you receive this message in error, please immediately notify the sender and delete it.
___________________________________________________________________________ ___________________________________________________________________________ _______________________________________________________
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com<http://symfony-project.com>

You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to sym...@googlegroups.com
To unsubscribe from this group, send email to
symfony2+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en

________________________________
Este mensaje y cualquier fichero anexo está dirigido exclusivamente a los destinatarios especificados. La información contenida puede ser confidencial y/o estar legalmente protegida y no necesariamente refleja la opinión de esta compañía. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo.

This message and any attached files are intended solely for the addressee/s identified herein. It may contain confidential and/or legally privileged information and may not ...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »