问题
Recently I moved a Symfony-system to another Server and got an error ever since. The technical details are: An apache 2.4 server on a windows server 2012 A fileserver which can be accessed by apache over the local network
When I moved the Symfony-page I deleted the cache. What happens now is, that I get these error-messages:
InvalidArgumentException: Unable to parse file "\\FILESERVER\PAGEPATH\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\DependencyInjection/../Resources/config\web.xml".
and
InvalidArgumentException: [WARNING 1549] failed to load external entity "file://///FILESERVER/PAGEPATH/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd" (in n/a - line 0, column 0)
[WARNING 3084] Element '{http://www.w3.org/2001/XMLSchema}import': Failed to locate a schema at location 'file://///FILESERVER/PAGEPATH/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd'. Skipping the import. (in in_memory_buffer - line 8, column 0)
[ERROR 1845] Element '{http://symfony.com/schema/dic/services}container': No matching global declaration available for the validation root. (in //FILESERVER/PAGEPATH/web/ - line 5, column 0)
What seems to be the problem, that in the first error, there is a mixture of slashes and backslashes in the path but I have no idea how to fix this issue.
回答1:
This issue is due to using UNC path (\\something). I had the same problem in Windows network enviroment with IIS and Symfony on another server. Unfortunatelly, I wasn't able to find solution. I ended up with having source code on the same machine and using local path.
EDIT: I found one more possible solution - symbolic link.
mklink /d C:\myroot \\FILESERVER\PAGEPATH
Now you can see under C:\myroot content of shared folder. I don't know if Apache will be happy with it but IIS doesn't have problem. And one more thing, be prepared for some performance issues due to network transfer.
回答2:
I am not sure whether this is related to your problem, but I once experienced problems parsing XML files when the schema definition file could not be loaded at parse time. The parser tried to load the XML schema file via network and in case the network connection failed, parsing the XML file failed as well.
If you are in production, for performance reasons you might not want a schema validation at all, so check whether the used parser offers a way to turn the automatic schema validation off. If however the error occurs in your development workflow, make sure that the schema URLs can actually be resolved from the webserver that parses the XML file.
回答3:
If the UNC path is the problem, maybe it works if you map the network share to a local drive and use the paths on the local drive to access the application.
Map \\FILESERVER\PAGEPATH
to a local drive, let's say W:
(W
from web
) then configure Apache's web root to W:\web
instead of \\FILESERVER\PAGEPATH\web
. I guess all the other path references are relative and nothing else needs to be changed.
(just a thought)
Update:
As a regular user, you can map a network share as a local drive and have it automatically re-connect on each logon by using the following command line:
C:\> net use W: \\FILESERVER\PAGEPATH /persistent:yes
Apache doesn't run as a regular user (I don't have a Windows system at hand but I think it runs as SYSTEM USER
). I cannot tell if the special users "logs on" when Windows starts up.
However, I think it is possible to run the command above (stored in a .cmd
file) using the Task Scheduler (on Windows 7 or newer), every time Windows starts.
来源:https://stackoverflow.com/questions/28836337/symfony-invalidargumentexception-while-parsing-web-xml