简体   繁体   中英

Symfony2 in production mode doesn't work because of FOSUserBundle

I'm trying to deploy my symfony2 project for university to my production server. In development mode, everything works fine.

So I cloned the project from our server to my hoster via git. parameters.yml is fine configured and composer was up to date, fixtures was loaded to database as well.

When I call the web folder over http symfony2 shows a blank page. prod.log shows the following in short:

[2015-11-12 21:16:41] request.CRITICAL: Exception thrown when handling an exception (Doctrine\Common\Persistence\Mapping\MappingException: Invalid mapping file 'FOS.UserBundle.Entity.User.orm.xml' for class 'FOS\UserBundle\Entity\User'. at /var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php line 86) {"exception":"[object] (Doctrine\\Common\\Persistence\\Mapping\\MappingException(code: 0): Invalid mapping file 'FOS.UserBundle.Entity.User.orm.xml' for class 'FOS\\UserBundle\\Entity\\User'. at /var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php:86)"} []

[2015-11-12 21:16:41] php.CRITICAL: Uncaught Exception: Invalid mapping file 'FOS.UserBundle.Entity.User.orm.xml' for class 'FOS\UserBundle\Entity\User'. {"type":1,"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php","line":86,"level":6143,"stack":[{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php","line":117,"function":"invalidMappingFile","class":"Doctrine\\Common\\Persistence\\Mapping\\MappingException","type":"::","args":["FOS\\UserBundle\\Entity\\User","FOS.UserBundle.Entity.User.orm.xml"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php","line":58,"function":"getElement","class":"Doctrine\\Common\\Persistence\\Mapping\\Driver\\FileDriver","type":"->","args":["FOS\\UserBundle\\Entity\\User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php","line":102,"function":"loadMetadataForClass","class":"Doctrine\\ORM\\Mapping\\Driver\\XmlDriver","type":"->","args":["FOS\\UserBundle\\Entity\\User","[object] (Doctrine\\ORM\\Mapping\\ClassMetadata: Doctrine\\ORM\\Mapping\\ClassMetadataInfo@00000000558022090000000071882094)"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php","line":116,"function":"loadMetadataForClass","class":"Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriverChain","type":"->","args":["FOS\\UserBundle\\Entity\\User","[object] (Doctrine\\ORM\\Mapping\\ClassMetadata: Doctrine\\ORM\\Mapping\\ClassMetadataInfo@00000000558022090000000071882094)"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php","line":332,"function":"doLoadMetadata","class":"Doctrine\\ORM\\Mapping\\ClassMetadataFactory","type":"->","args":["[object] (Doctrine\\ORM\\Mapping\\ClassMetadata: Doctrine\\ORM\\Mapping\\ClassMetadataInfo@00000000558022090000000071882094)",null,false,[]]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php","line":216,"function":"loadMetadata","class":"Doctrine\\Common\\Persistence\\Mapping\\AbstractClassMetadataFactory","type":"->","args":["Hsd\\Bundle\\ClickerBackendBundle\\Entity\\User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php","line":265,"function":"getMetadataFor","class":"Doctrine\\Common\\Persistence\\Mapping\\AbstractClassMetadataFactory","type":"->","args":["Hsd\\Bundle\\ClickerBackendBundle\\Entity\\User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php","line":67,"function":"getClassMetadata","class":"Doctrine\\ORM\\EntityManager","type":"->","args":["Hsd\\Bundle\\ClickerBackendBundle\\Entity\\User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php","line":50,"function":"createRepository","class":"Doctrine\\ORM\\Repository\\DefaultRepositoryFactory","type":"->","args":["[object] (Doctrine\\ORM\\EntityManager: {})","Hsd\\Bundle\\ClickerBackendBundle\\Entity\\User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php","line":665,"function":"getRepository","class":"Doctrine\\ORM\\Repository\\DefaultRepositoryFactory","type":"->","args":["[object] (Doctrine\\ORM\\EntityManager: {})","Hsd\\Bundle\\ClickerBackendBundle\\Entity\\User"]},{"file":"/var/www/virtual/username/symfonyproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Doctrine/UserManager.php","line":40,"function":"getRepository","class":"Doctrine\\ORM\\EntityManager","type":"->","args":["Hsd\\Bundle\\ClickerBackendBundle\\Entity\\User"]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":835,"function":"__construct","class":"FOS\\UserBundle\\Doctrine\\UserManager","type":"->","args":["[object] (Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactory: {})","[object] (FOS\\UserBundle\\Util\\Canonicalizer: {})","[object] (FOS\\UserBundle\\Util\\Canonicalizer: {})","[object] (Doctrine\\ORM\\EntityManager: {})","Hsd\\Bundle\\ClickerBackendBundle\\Entity\\User"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getFosUser_UserManagerService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1635,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->","args":["fos_user.user_manager"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getFosUser_UserProvider_UsernameService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1653,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->","args":["fos_user.user_provider.username"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getSecurity_Authentication_ManagerService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1151,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->","args":["security.authentication.manager"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getSecurity_AuthorizationCheckerService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1524,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->","args":["security.authorization_checker",2]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getTwigService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/appProdProjectContainer.php","line":1550,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->","args":["twig"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2155,"function":"getTwig_Controller_ExceptionService","class":"appProdProjectContainer","type":"->","args":[]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/classes.php","line":2934,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->","args":["twig.controller.exception"]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/classes.php","line":2559,"function":"createController","class":"Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver","type":"->","args":["twig.controller.exception:showAction"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3102,"function":"getController","class":"Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver","type":"->","args":["[object] (Symfony\\Component\\HttpFoundation\\Request: GET /de/ HTTP/1.1\r\nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding:   gzip, deflate\r\nAccept-Language:   de,en-US;q=0.7,en;q=0.3\r\nAuthorization:     \r\nCache-Control:     max-age=0\r\nConnection:        close\r\nCookie:            hl=de\r\nHost:              dev.mywebsite.de\r\nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0\r\nX-Forwarded-For:   91.136.154.136\r\nX-Forwarded-Port:  80\r\nX-Forwarded-Proto: http\r\nX-Php-Ob-Level:    1\r\n\r\n)"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3071,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->","args":["[object] (Symfony\\Component\\HttpFoundation\\Request: GET /de/ HTTP/1.1\r\nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding:   gzip, deflate\r\nAccept-Language:   de,en-US;q=0.7,en;q=0.3\r\nAuthorization:     \r\nCache-Control:     max-age=0\r\nConnection:        close\r\nCookie:            hl=de\r\nHost:              dev.mywebsite.de\r\nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0\r\nX-Forwarded-For:   91.136.154.136\r\nX-Forwarded-Port:  80\r\nX-Forwarded-Proto: http\r\nX-Php-Ob-Level:    1\r\n\r\n)",2]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3222,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->","args":["[object] (Symfony\\Component\\HttpFoundation\\Request: GET /de/ HTTP/1.1\r\nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding:   gzip, deflate\r\nAccept-Language:   de,en-US;q=0.7,en;q=0.3\r\nAuthorization:     \r\nCache-Control:     max-age=0\r\nConnection:        close\r\nCookie:            hl=de\r\nHost:              dev.mywebsite.de\r\nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0\r\nX-Forwarded-For:   91.136.154.136\r\nX-Forwarded-Port:  80\r\nX-Forwarded-Proto: http\r\nX-Php-Ob-Level:    1\r\n\r\n)",2,false]},{"file":"/var/www/virtual/username/symfonyproject/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php","line":50,"function":"handle","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->","args":["[object] (Symfony\\Component\\HttpFoundation\\Request: GET /de/ HTTP/1.1\r\nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding:   gzip, deflate\r\nAccept-Language:   de,en-US;q=0.7,en;q=0.3\r\nAuthorization:     \r\nCache-Control:     max-age=0\r\nConnection:        close\r\nCookie:            hl=de\r\nHost:              dev.mywebsite.de\r\nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0\r\nX-Forwarded-For:   91.136.154.136\r\nX-Forwarded-Port:  80\r\nX-Forwarded-Proto: http\r\nX-Php-Ob-Level:    1\r\n\r\n)",2,false]},{"function":"onKernelException","class":"Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener","type":"->","args":["[object] (Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent: {})","kernel.exception","[object] (Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher: {})"]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/classes.php","line":2272,"function":"call_user_func","args":[["[object] (Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener: {})","onKernelException"],"[object] (Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent: {})","kernel.exception","[object] (Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher: {})"]},{"file":"/var/www/virtual/username/symfonyproject/app/cache/prod/classes.php","line":2201,"function":"doDispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[[["[object] (JMS\\I18nRoutingBundle\\EventListener\\LocaleChoosingListener: {})","onKernelException"],["[object] (Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener: {})","onKernelException"]],"kernel.exception","[object] (Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent: {})"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3141,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":["kernel.exception","[object] (Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent: {})"]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3077,"function":"handleException","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->","args":["[object] (Doctrine\\Common\\Persistence\\Mapping\\MappingException(code: 0): Invalid mapping file 'FOS.UserBundle.Entity.User.orm.xml' for class 'FOS\\UserBundle\\Entity\\User'. at /var/www/virtual/username/symfonyproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php:86)","[object] (Symfony\\Component\\HttpFoundation\\Request: GET /de/ HTTP/1.1\r\nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding:   gzip, deflate\r\nAccept-Language:   de,en-US;q=0.7,en;q=0.3\r\nAuthorization:     \r\nCache-Control:     max-age=0\r\nConnection:        close\r\nCookie:            hl=de\r\nHost:              dev.mywebsite.de\r\nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0\r\nX-Forwarded-For:   91.136.154.136\r\nX-Forwarded-Port:  80\r\nX-Forwarded-Proto: http\r\nX-Php-Ob-Level:    1\r\n\r\n)",1]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":3222,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->","args":["[object] (Symfony\\Component\\HttpFoundation\\Request: GET /de/ HTTP/1.1\r\nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding:   gzip, deflate\r\nAccept-Language:   de,en-US;q=0.7,en;q=0.3\r\nAuthorization:     \r\nCache-Control:     max-age=0\r\nConnection:        close\r\nCookie:            hl=de\r\nHost:              dev.mywebsite.de\r\nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0\r\nX-Forwarded-For:   91.136.154.136\r\nX-Forwarded-Port:  80\r\nX-Forwarded-Proto: http\r\nX-Php-Ob-Level:    1\r\n\r\n)",1,true]},{"file":"/var/www/virtual/username/symfonyproject/app/bootstrap.php.cache","line":2444,"function":"handle","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->","args":["[object] (Symfony\\Component\\HttpFoundation\\Request: GET /de/ HTTP/1.1\r\nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding:   gzip, deflate\r\nAccept-Language:   de,en-US;q=0.7,en;q=0.3\r\nAuthorization:     \r\nCache-Control:     max-age=0\r\nConnection:        close\r\nCookie:            hl=de\r\nHost:              dev.mywebsite.de\r\nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0\r\nX-Forwarded-For:   91.136.154.136\r\nX-Forwarded-Port:  80\r\nX-Forwarded-Proto: http\r\nX-Php-Ob-Level:    1\r\n\r\n)",1,true]},{"file":"/var/www/virtual/username/symfonyproject/web/app.php","line":28,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"->","args":["[object] (Symfony\\Component\\HttpFoundation\\Request: GET /de/ HTTP/1.1\r\nAccept:            text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding:   gzip, deflate\r\nAccept-Language:   de,en-US;q=0.7,en;q=0.3\r\nAuthorization:     \r\nCache-Control:     max-age=0\r\nConnection:        close\r\nCookie:            hl=de\r\nHost:              dev.mywebsite.de\r\nUser-Agent:        Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0\r\nX-Forwarded-For:   91.136.154.136\r\nX-Forwarded-Port:  80\r\nX-Forwarded-Proto: http\r\nX-Php-Ob-Level:    1\r\n\r\n)"]}]} []

What did I try to fix it?

  • delete app/cache/*
  • delete vendor/* and run composer update again

Both server (dev and prod) run PHP 5.6.12

Can anyone give me a clue whats wrong?

The "solution":

add libxml_disable_entity_loader(false); to app.php in the web folder.


The workaround was found on a github issue .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM