Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#16470 closed defect (invalid)

dojo/text - load ANY file

Reported by: gerhard presser Owned by: Rawld Gill
Priority: undecided Milestone: tbd
Component: Loader Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:


I want to load an text-file from outside the dojo-base using the AMD-loader

e.g. the widget


I get following error:

Zeitstempel: 13.12.2012 08:51:25
Fehler: Error: irrationalPath
Zeile: 15

it seems this is an intended restriction!? what's the reason?

Change History (6)

comment:1 Changed 10 years ago by ben hockey

Resolution: invalid
Status: newclosed

the reason is that your relative path doesn't make sense. from the id "com/foo/MyWidget" if you try to resolve "../../../file.txt" you end up going beyond the first segment of the module you're resolving relative to so it doesn't make sense.

to fix this you can either use the full path of the file ("dojo/text!/full/path/to/file.txt") or put file.txt in a location that the loader knows how to map to a url - maybe use a "docs" package (or map a "docs" path) "dojo/text!docs/file.txt"

comment:2 Changed 10 years ago by gerhard presser

I repackaged dojo so I load it e.g.


actually I don't try to load a static file from the widget, but to load an dynamic file using a servlet-method

all my servlets are based at


using the absolute url


tries to load the file from


which isn't right for my case. is there any better way to load that content? the servlet provides some user-dependent initialization properties. It just has to be loaded once per widget-definition.

comment:3 Changed 10 years ago by ben hockey

when i try it, i don't get the same results you described


results in a request to:


do you have anything more that might help me

  • can you paste your dojoConfig
  • are you sure you have the leading '/'
  • is it possible to try "dojo/text!http://host:port/contextroot/servlet.method/path/to/servlet"

comment:4 in reply to:  3 Changed 10 years ago by gerhard presser


works - but is not an option - I cannot include the contextroot


works - but the same here - absolute path is not a valid option

there's no special dojoConfig

the exception I get seems to be 'homemade' - what is this check for? security? since I may load absolute urls, why can't I load any relative url?

comment:5 Changed 10 years ago by ben hockey

the exception is because you are making a request of the loader that is illogical.

your misunderstanding is not uncommon - it seems like if the module id "com/foo/MyWidget" maps to the url with a path of "/contextroot/scripts/com/foo/MyWidget" that then a relative reference of "../../../file.txt" should be able to be resolved using the path of that module but this is not how the loader resolves references - relative references are resolved relative to the module ID *first* and then the loader will use logic to try and map the resolved module ID to a URL. since the IDs can't be resolved to something sensible, the loader throws an error.

when you use an absolute URL (starting with '/' or 'http'), the loader realizes that you have specifically asked for a URL and will give you back what you asked for.

in your case i would expect that there is probably some way you can provide the right data to configure the loader so that a "servlets" path or package points to this path ("contextroot/servlet.method") so then you could use "dojo/text!servlets/path/to/servlet" or something like that.

comment:6 Changed 9 years ago by gerhard presser

I'm now using my own AMD-plugin to xhr-load any url - this is OK for me. ticket can stay closed.

Note: See TracTickets for help on using tickets.