Skip to Content

Getting "[ODataMetadata] initial loading of metadata failed" while running UI5 module.

Hi everyone,

I am trying to build a simple project with :

  1. database module containing user.hdbcds table

  2. A node.js module with an .xsodata service exposing this table.


    This module is working fine and giving me the URI. If I change the URI from /index.js to /xsodata/user.xsodata/Users I am getting the JSON with the data.







    3. When I try to run the UI5 module with this service binded to the list , The list is not populated.



    mta.yaml :

    ID: Try_UI5_List
    _schema-version: '2.1'
    version: 0.0.1
    modules:
      - name: user_db
        type: hdb
        path: user_db
        requires:
          - name: hdi_user_db
      - name: user_js
        type: nodejs
        path: user_js
        provides:
          - name: user_js_api
            properties:
              url: '${default-url}'
        requires:
          - name: hdi_user_db
          - name: user_db
      - name: user_ui
        type: html5
        path: user_ui
        parameters:
          disk-quota: 256M
          memory: 256M
        build-parameters:
          builder: grunt
        requires:
          - name: uaa_Try_UI5_List
          - name: dest_Try_UI5_List
          - name: user_js_api
            properties:
              name: user_js_be
              url: '~{url}'
            group: destinations
    resources:
      - name: hdi_user_db
        properties:
          hdi-container-name: '${service-name}'
        type: com.sap.xs.hdi-container
      - name: uaa_Try_UI5_List
        parameters:
          path: ./xs-security.json
          service-plan: application
          service: xsuaa
        type: org.cloudfoundry.managed-service
      - name: dest_Try_UI5_List
        parameters:
          service-plan: lite
          service: destination
        type: org.cloudfoundry.managed-service
    
    
    xs-app.json :
    
    
    {
      "welcomeFile": "/user_ui/index.html",
      "authenticationMethod": "route",
      "logout": {
        "logoutEndpoint": "/do/logout"
      },
      "routes": [
        {
          "source": "^/user_ui/(.*)$",
          "target": "$1",
          "localDir": "webapp"
        },
        {
        	"source": "^/xsodata/user.xsodata/.*$",
        	"destination": "user_js_be"
        }
      ]
    }
    
    manifest.json (inside webapp folder)
    
    
    {
    	"_version": "1.8.0",
    	"sap.app": {
    		"id": "user_ui.user_ui",
    		"type": "application",
    		"i18n": "i18n/i18n.properties",
    		"applicationVersion": {
    			"version": "1.0.0"
    		},
    		"title": "{{appTitle}}",
    		"description": "{{appDescription}}",
    		"sourceTemplate": {
    			"id": "html5moduletemplates.basicSAPUI5ApplicationProjectModule",
    			"version": "1.40.12"
    		},
    
    
    		"dataSources": {
    			"local_data": {
    				"uri": "model/local.json",
    				"type": "JSON"
    			},
    			"user.xsodata": {
    				"uri": "/xsodata/user.xsodata/",
    				"type": "OData",
    				"settings": {
    					"odataVersion": "2.0",
    					"localUri": "localService/metadata.xml"
    				}
    			}
    			
    		}
    	},
    
    
    	"sap.ui": {
    		"technology": "UI5",
    		"icons": {
    			"icon": "",
    			"favIcon": "",
    			"phone": "",
    			"phone@2": "",
    			"tablet": "",
    			"tablet@2": ""
    		},
    		"deviceTypes": {
    			"desktop": true,
    			"tablet": true,
    			"phone": true
    		},
    		"supportedThemes": [
    			"sap_hcb",
    			"sap_belize"
    
    
    		]
    	},
    
    
    	"sap.ui5": {
    		"rootView": {
    			"viewName": "user_ui.user_ui.view.View1",
    			"type": "XML"
    		},
    		"dependencies": {
    			"minUI5Version": "1.60.1",
    			"libs": {
    				"sap.ui.core": {},
    				"sap.m": {},
    				"sap.ui.layout": {},
    				"sap.ushell": {},
    				"sap.collaboration": {},
    				"sap.ui.comp": {},
    				"sap.uxap": {}
    			}
    		},
    		"contentDensities": {
    			"compact": true,
    			"cozy": true
    		},
    		"models": {
    			"i18n": {
    				"type": "sap.ui.model.resource.ResourceModel",
    				"settings": {
    					"bundleName": "user_ui.user_ui.i18n.i18n"
    				}
    			},
    			"local": {
    				"type": "sap.ui.model.json.JSONModel",
    				"dataSource": "local_data"
    			},
    			"": {
    				"type": "sap.ui.model.odata.v2.ODataModel",
    				"dataSource": "user.xsodata"
    			}
    		},
    		"resources": {
    			"css": [{
    				"uri": "css/style.css"
    			}]
    		},
    		"routing": {
    			"config": {
    				"routerClass": "sap.m.routing.Router",
    				"viewType": "XML",
    				"async": true,
    				"viewPath": "user_ui.user_ui.view",
    				"controlAggregation": "pages",
    				"controlId": "idAppControl",
    				"clearControlAggregation": false
    			},
    			"routes": [{
    				"name": "RouteView1",
    				"pattern": "RouteView1",
    				"target": ["TargetView1"]
    			}],
    			"targets": {
    				"TargetView1": {
    					"viewType": "XML",
    					"transition": "slide",
    					"clearControlAggregation": false,
    					"viewName": "View1"
    				}
    			}
    		}
    	}
    }
    
    
    index.html : 
    
    
    <!DOCTYPE HTML>
    <html>
    
    
    	<head>
    		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
    		<meta charset="UTF-8">
    
    
    		<title>user_ui</title>
    
    
    		<script id="sap-ui-bootstrap"
    			src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
    			data-sap-ui-async="true"
    			data-sap-ui-libs="sap.m"
    			data-sap-ui-theme="sap_belize"
    			data-sap-ui-compatVersion="edge"
    			data-sap-ui-resourceroots='{"user_ui.user_ui": "./"}'>
    		</script>
    
    
    		<link rel="stylesheet" type="text/css" href="css/style.css">
    
    
    		<script>
    			sap.ui.getCore().attachInit(function() {
    				new sap.m.Shell({
    					app: new sap.ui.core.ComponentContainer({
    						height : "100%",
    						name : "user_ui.user_ui"
    					})
    				}).placeAt("content");
    			});
    		</script>
    	</head>
    
    
    	<body class="sapUiBody" id="content">
    	</body>
    
    
    </html>
    
    
    component.js :
    
    
    sap.ui.define([
    	"sap/ui/core/UIComponent",
    	"sap/ui/Device",
    	"user_ui/user_ui/model/models"
    ], function (UIComponent, Device, models) {
    	"use strict";
    
    
    	return UIComponent.extend("user_ui.user_ui.Component", {
    
    
    		metadata: {
    			manifest: "json"
    		},
    
    
    		/**
    		 * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
    		 * @public
    		 * @override
    		 */
    		init: function () {
    			// call the base component's init function
    			UIComponent.prototype.init.apply(this, arguments);
    
    
    			// enable routing
    			this.getRouter().initialize();
    
    
    			// set the device model
    			this.setModel(models.createDeviceModel(), "device");
    		}
    	});
    });
    
    View1.view.xml :
    
    
    <mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="user_ui.user_ui.controller.View1" displayBlock="true">
    	<App id="idAppControl">
    		<pages>
    			<Page title="{i18n>title}">
    				<content>
    					
    					<sap.ui.layout.form:SimpleForm xmlns:sap.ui.layout.form="sap.ui.layout.form" xmlns:sap.ui.core="sap.ui.core" editable="true" layout="ResponsiveGridLayout" id="__form0">
    				        <sap.ui.layout.form:content>
    				            <sap.ui.core:Title text="{i18n>userEntry}" id="__title0"/>
    				            <Label text="{i18n>userId}" id="__label0"/>
    				            <Input width="100%" id="__input0" value="{local>/User/UserId}"/>
    				            <Label text="{i18n>firstName}" id="__label1"/>
    				            <Input width="100%" id="__input1" value="{local>/User/FirstName}"/>
    				            <Label text="{i18n>lastName}" width="100%" id="__label2"/>
    				            <Input width="100%" id="__input2" value="{local>/User/LastName}"/>
    				            <Label text="{i18n>email}" width="100%" id="__label3"/>
    				            <Input width="100%" id="__input3" value="{local>/User/Email}"/>
    				        
    				            </sap.ui.layout.form:content>
    				    </sap.ui.layout.form:SimpleForm>
    					
    					<List noDataText="Drop list items here" items="{/Users}" id="list0" mode="SingleSelectMaster" selectionChange="onSelectionChange">
    					
    					    <items>
    					
    					        <StandardListItem type="Active" title="{UserId}{FirstName}{LastName}" description="{Email}" id="item0"/>
    					
    					    </items>
    					
    					<headerToolbar>
    					
    					    <Toolbar width="100%" id="toolbar1">
    					
    					        <content>
    					
    					            <Button xmlns="sap.m" id="button0" text="{i18n>create}" press="onCreate"/>
    					
    					            <Button xmlns="sap.m" text="{i18n>delete}" id="button1" press="onDelete"/>
    					
    					        </content>
    					
    					    </Toolbar>
    					
    					</headerToolbar>
    					
    					</List>
    				</content>
    			</Page>
    		</pages>
    	</App>
    </mvc:View>
    
    View1.controller.js : 
    
    
    sap.ui.define([
    	"sap/ui/core/mvc/Controller",
    	"sap/m/MessageBox"
    ], function (Controller) {
    	"use strict";
    	return Controller.extend("user_ui.user_ui.controller.View1", {
    		onInit: function () {},
    		/**
    		 *@memberOf user_ui.user_ui.controller.View1
    		 */
    		onCreate: function () {
    			//This code was generated by the layout editor.
    			var oLocal = this.getView().getModel("local");
    			var oService = this.getView().getModel();
    			var oBundle = this.getView().getModel("i18n");
    			var oNewUser = oLocal.getProperty("/User");
    			oService.create("/Users", oNewUser, {
    				success: function () {
    					sap.m.MessageBox.alert(oBundle.getProperty("createSuccessMessage"));
    				},
    				error: function (oError) {
    					//sap.m.MessageBox.alert("hi");
    					var response = JSON.parse(oError.responseText);
    					var errorMessage = response.error.message.value;
    					sap.m.MessageBox.alert(oBundle.getProperty("createErrorMessage") + errorMessage);
    				}
    			});
    		},
    		/**
    		 *@memberOf user_ui.user_ui.controller.View1
    		 */
    		onSelectionChange: function (oEvent) {
    			//This code was generated by the layout editor.
    			var oLocal = this.getView().getModel("local");
    			var selectedItem = oEvent.getSource().getSelectedItem();
    			var path = selectedItem.getBindingContext().getPath();
    			oLocal.setProperty("/SelectedUserPath", path);
    		},
    		/**
    		 *@memberOf user_ui.user_ui.controller.View1
    		 */
    		onDelete: function (oEvent) {
    			//This code was generated by the layout editor.
    			var oLocal = this.getView().getModel("local");
    			var oService = this.getView().getModel();
    			var oBundle = this.getView().getModel("i18n");
    			
    			var path = oLocal.getProperty("/SelectedUserPath");
    			if(path === "") {
    				sap.m.MessageBox.alert(oBundle.getProperty("deleteNoSelectionMessage"));
    			}
    			else {
    				oService.remove(path, {
    					success: function() {
    						sap.m.MessageBox.alert(oBundle.getProperty("deleteSuccessMessage"));
    						oLocal.setProperty("/SelectedUserPath","");
    					},
    					error: function(oError) {
    						var response=JSON.parse(oError.responseText);
    						var errorMessage = response.error.message.value;
    						
    						sap.m.MessageBox.alert(oBundle.getProperty("deleteErrorMessage")+errorMessage);
    					}
    				});
    			}
    		}
    	});
    });
    
    localService/metadata.xml :
    
    
    <edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
    	<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0">
    		<Schema xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
    			xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"
    			Namespace="default">
    			<EntityType Name="UsersType">
    				<Key>
    					<PropertyRef Name="UserId"/>
    				</Key>
    				<Property Name="UserId" Type="Edm.Int32" Nullable="false"/>
    				<Property Name="FirstName" Type="Edm.String" MaxLength="40"/>
    				<Property Name="LastName" Type="Edm.String" MaxLength="40"/>
    				<Property Name="Email" Type="Edm.String" MaxLength="255"/>
    			</EntityType>
    			<EntityContainer Name="v2" m:IsDefaultEntityContainer="true">
    				<EntitySet Name="Users" EntityType="default.UsersType"/>
    			</EntityContainer>
    		</Schema>
    	</edmx:DataServices>
    </edmx:Edmx>
    
    local.json : 
    
    
    {
    	"User": {
    		"UserId": 0,
    		"FirstName": "John",
    		"LastName": "Doe",
    		"Email": "jd@no.com"
    	},
    	"SelectedUserPath": ""
    }
    
01.png (11.5 kB)
02.png (78.9 kB)
03.png (12.6 kB)
04.png (3.8 kB)
05.png (10.4 kB)
05.png (10.4 kB)
06.png (5.3 kB)
07.png (36.0 kB)
08.png (57.7 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.