FOSRestBundle icon indicating copy to clipboard operation
FOSRestBundle copied to clipboard

Failed to locate a schema at location

Open scasei opened this issue 12 years ago • 31 comments

at http://friendsofsymfony.github.io/schema/rest/ there is a "404 - There isn't a GitHub Page here." and symfony comes with: failed to load external entity "in_memory_buffer"
when I do: sonata_api_media: type: rest prefix: /api resource: "@SonataMediaBundle/Resources/config/routing/api.xml"

scasei avatar Feb 18 '14 09:02 scasei

remove type: rest that is only necessary if you want FOSRestBundle to auto discover the action methods, which you do not seem to want, since you are including an xml file with explicitly defined routes.

/cc @rande

lsmith77 avatar Feb 20 '14 20:02 lsmith77

// cc @Bladrak

rande avatar Feb 20 '14 20:02 rande

that may be right, but i have followed the instructions on how to setup up media rest api and got an error, so from my side of view one thing has to be changed: the instructions or the xmlns

scasei avatar Feb 21 '14 07:02 scasei

@lsmith77 here's the api.xml routing file:

<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://friendsofsymfony.github.com/schema/rest"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://friendsofsymfony.github.com/schema/rest https://raw.github.com/FriendsOfSymfony/FOSRestBundle/master/Resources/config/schema/routing/rest_routing-1.0.xsd">

    <import type="rest" resource="sonata.media.controller.api.gallery" name-prefix="sonata_api_media_gallery_" />
    <import type="rest" resource="sonata.media.controller.api.media" name-prefix="sonata_api_media_media_" />

</routes>

When we remove the type: rest from the main routing configuration, we get the following exception:

Cannot import resource "/web/Ekino/Sonata/src/sf2-sonata-sandbox/vendor/sonata-project/news-bundle/Resources/config/routing/api.xml" from "/web/Ekino/Sonata/src/sf2-sonata-sandbox/app/config/routing_api.yml". ([ERROR 1845] Element '{http://friendsofsymfony.github.com/schema/rest}routes': No matching global declaration available for the validation root. (in /web/Ekino/Sonata/src/sf2-sonata-sandbox/web/ - line 5, column 0))

Not sure where the problem is precisely, but I'm unable to reproduce @scasei's issue.

Bladrak avatar Feb 21 '14 09:02 Bladrak

I followed the instruction on this page: http://sonata-project.org/bundles/media/master/doc/reference/api.html Then I tried to open the route '/api/doc' and got the error. Should I grab more information?

Full error description: FileLoaderLoadException: Cannot import resource "C:\wamp\www\project\vendor\sonata-project\media-bundle/Resources/config/routing/api.xml" from "C:/wamp/www/project/app/config\routing.yml". ([WARNING 1549] failed to load external entity "in_memory_buffer" (in n/a - line 0, column 0) [WARNING 3084] Element '{http://www.w3.org/2001/XMLSchema}import': Failed to locate a schema at location 'in_memory_buffer'. Skipping the import. (in in_memory_buffer - line 9, column 0) [ERROR 1845] Element '{http://friendsofsymfony.github.com/schema/rest}routes': No matching global declaration available for the validation root. (in file:///C:/wamp/www/project/web/ - line 5, column 0))

scasei avatar Feb 21 '14 09:02 scasei

This path seems wrong in your log: C:/wamp/www/project/app/config\routing.yml; I'm not familiar enough with Windows to help you with that though...

I've noticed that there was an issue with an earlier version of Symfony (2.0.15 - cf https://github.com/symfony/symfony/issues/4479). Any idea @lsmith77?

Bladrak avatar Feb 21 '14 10:02 Bladrak

"This path seems wrong in your log": You mean the mixed slahes? Thats not a problem for windows PHP. Will be translated slightly. Additionally the error occurs if I insert the 'sonata_api_media' route from instructions and disapear when I delete the route. (means that routing.yml will be found)

scasei avatar Feb 21 '14 10:02 scasei

Yep, that's what I meant. Ok then, didn't know about that.

I think the issue comes from the fact that you're unable to parse the http://friendsofsymfony.github.com/schema/rest XML schema definition that's at https://raw.github.com/FriendsOfSymfony/FOSRestBundle/master/Resources/config/schema/routing/rest_routing-1.0.xsd

I think we should wait for @lsmith77 insight about that. :)

Bladrak avatar Feb 21 '14 10:02 Bladrak

are you using the latest version of the Bundle?

lsmith77 avatar Feb 21 '14 11:02 lsmith77

Our requirement for FOSRestBundle in SonataMediaBundle is "friendsofsymfony/rest-bundle": "~1.1". Should we require ~1.2 instead?

Bladrak avatar Feb 21 '14 11:02 Bladrak

~1.1 should be fine .. should use any 1.X release above 1.1

lsmith77 avatar Feb 21 '14 11:02 lsmith77

@tobion do you have a hint here?

lsmith77 avatar Feb 21 '14 11:02 lsmith77

from my composer.lock:

            "name": "friendsofsymfony/rest-bundle",
            "version": "1.2.2",
            "target-dir": "FOS/RestBundle",
            "source": {
                "type": "git",
                "url": "https://github.com/FriendsOfSymfony/FOSRestBundle.git",
                "reference": "7c81a1879c5d8a3727932674509e96b2bb7a796e"
            },

scasei avatar Feb 21 '14 12:02 scasei

Hm the errror looks rather strange. Where does "in_memory_buffer" come from? Can't see it referenced anywhere. Probably something internal to PHP. The only possible issue I see is that https://raw.github.com/FriendsOfSymfony/FOSRestBundle/master/Resources/config/schema/routing/rest_routing-1.0.xsd is sent with a text mime type instead of xml. So maybe that's the reason why it cannot be used for validation.

Tobion avatar Feb 23 '14 16:02 Tobion

My server software signature: Apache/2.2.26 (Win32) mod_ssl/2.2.26 OpenSSL/1.0.1e PHP/5.5.8

Is there something i could test or investigate?

scasei avatar Feb 23 '14 16:02 scasei

Seems to be a php bug. See symfony/symfony#9731

Tobion avatar Mar 12 '14 22:03 Tobion

Up ! I followed every possible way to solve this issue, but I keep getting this error message :

[2/2] FileLoaderLoadException: Cannot import resource "C:\wamp\www\sandbox\vendor\sonata-project\news-bundle/Resources/config/routing/api.xml" from "C:/wamp/www/sandbox/app/config\routing_api.yml". ([WARNING 1549] failed to load external entity "in_memory_buffer" (in n/a - line 0, column 0) [WARNING 3084] Element '{http://www.w3.org/2001/XMLSchema}import': Failed to locate a schema at location 'in_memory_buffer'. Skipping the import. (in in_memory_buffer - line 9, column 0) [ERROR 1845] Element '{http://friendsofsymfony.github.com/schema/rest}routes': No matching global declaration available for the validation root. (in file:///C:/wamp/www/sandbox/web/ - line 5, column 0))

Help!

ghost avatar Apr 03 '14 10:04 ghost

@Soulaimaniya What do your api.xml and routing_api.yml files look like?

xabbuh avatar Apr 03 '14 14:04 xabbuh

This is my api.xml :

<import type="rest" resource="sonata.news.controller.api.post" name-prefix="sonata_api_news_post_" />
<import type="rest" resource="sonata.news.controller.api.comment" name-prefix="sonata_api_news_comment_" />

and this is how my routing_api.yml :

NelmioApiDocBundle: resource: "@NelmioApiDocBundle/Resources/config/routing.yml" prefix: /doc

sonata_api_news: type: rest prefix: /news resource: "@SonataNewsBundle/Resources/config/routing/api.xml"

sonata_api_media: type: rest prefix: /media resource: "@SonataMediaBundle/Resources/config/routing/api.xml"

sonata_api_notification: type: rest prefix: /notification resource: "@SonataNotificationBundle/Resources/config/routing/api.xml"

sonata_api_ecommerce_product: type: rest prefix: /ecommerce resource: "@SonataProductBundle/Resources/config/routing/api.xml"

sonata_api_ecommerce_order: type: rest prefix: /ecommerce resource: "@SonataOrderBundle/Resources/config/routing/api.xml"

sonata_api_ecommerce_invoice: type: rest prefix: /ecommerce resource: "@SonataInvoiceBundle/Resources/config/routing/api.xml"

sonata_api_ecommerce_customer: type: rest prefix: /ecommerce resource: "@SonataCustomerBundle/Resources/config/routing/api.xml"

sonata_api_ecommerce_basket: type: rest prefix: /ecommerce resource: "@SonataBasketBundle/Resources/config/routing/api.xml"

sonata_api_page: type: rest prefix: /page resource: "@SonataPageBundle/Resources/config/routing/api.xml"

sonata_api_user: type: rest prefix: /user resource: "@SonataUserBundle/Resources/config/routing/api.xml"

I've tried every single instruction, everything fails.

ghost avatar Apr 03 '14 14:04 ghost

It should be fixed by https://github.com/symfony/symfony/pull/10493 which is in v2.3.12. Can you update symfony in your project and try again?

Tobion avatar Apr 03 '14 15:04 Tobion