Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading library.js from bad path

I have updated OpenUI5 of my project from 1.42.7 to 1.60.12 (LTS)

If I try to run the app with the new version, I have this error:

Uncaught Error: failed to load 'sap/ui/core/library.js' from resources/sap/ui/core/library.js: 404 - Not Found**

error

The tree structure of my project has OpenUI5 files into resources/openui path:

current project folder structure

In index.html, I set src in this mode:

<script id="sap-ui-bootstrap"
  src="resources/openui/sap-ui-core.js"
  data-sap-ui-theme="sap_belize"
  data-sap-ui-xx-bindingSyntax="complex"
  data-sap-ui-libs="sap.m"
  data-sap-ui-preload=""
  data-sap-ui-resourceroots='{
    "ui5bp": "./",
    "model": "./model"
  }'
></script>

It seems that the first call of sap-ui-core.js finishes correctly (from Webcontent/resources/openui) but then the call of library.js is called from Webcontent/resources/, not from Webcontent/resources/openui.

In 1.42 version, all works fine.
Note: if I try to retrieve OpenUI5 resources from CDN, all works fine...

src="https://openui5.hana.ondemand.com/1.60.12/resources/sap-ui-core.js"
like image 284
padibro Avatar asked Nov 02 '25 05:11

padibro


1 Answers

Option 1 (recommended)

Move the UI5 resources to the resources folder directly underneath.

˅ 📂resources
  ˃ 📁openui
  ˅ 📂sap
    ˃ 📁base
    ˃ 📁f
    ˃ 📁m
    ...
  ...
  sap-ui-core.js

According to the topic Bootstrapping: Loading and Initializing - Initialization Process, UI5 will try to fetch library resources from the following path by default:

Library bootstrap file /<context-path>/resources/<library-name>/library(-preload).js

Having a deviating path (/resources/openui/<library-name>/ in between) makes fetching the library files incompatible with default settings.

Option 2 (without changing the folder structure)

Define a new default base URL in index.html as early as possible. E.g. via the global configuration object:

<script>
  window["sap-ui-config"] = {
    resourceRoots: {
      "": "./resources/openui/", // <-- new base URL
      "ui5bp": "./",
      // ...
    },
    libs: "sap.ui.core, sap.m",
    async: true,
    theme: "sap_belize",
    compatVersion: "edge",
    // ...
  };
</script>
<script id="sap-ui-bootstrap" src="resources/openui/sap-ui-core.js"></script>

This one works too as resolving "" will always work as a fallback

Note that the empty prefix ("") will always match and thus serves as a fallback for any search. source

like image 126
Boghyon Hoffmann Avatar answered Nov 04 '25 10:11

Boghyon Hoffmann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!