I have a UI5 application in Neo that currently calls a Java servlet (named UserInfo.java) which uses a remote function call to return an encrypted user token. I have followed the steps in Invoke ABAP Function Modules in On-Premise ABAP Systems to re-create the Java servlet in Cloud Foundry and it appears to be running. When I try to run the UI5 application in Cloud Foundry, however, I receive a 404 (Not Found) error on the Java application. We are using the following jquery statement to call the servlet:
jQuery.sap.syncGet('/userinfo/UserInfo').data
Here is the entry for the servlet in the xs-app.json of the UI5 application:
Here is how the servlet entry looks in the neo-app.json of the original UI5 application running in Neo:
What am I missing?
UPDATE: It appears the only way to access a servlet from UI5 in CF is by creating a standalone app router in my project, so I let BAS generate a brand new multi-target application, added a standalone app router module and a UI5 module. By following some other blogs, I converted the java servlet to a maven project (I guess this was required??), created and bound its necessary services in the CF cockpit, made the necessary adjustments to the xs-app.json, the mta.yaml, and the destinations.json files in the multi-target app, and added a small Text control to the UI5 view (this UI5 app is completely bare-bones and not the original app, by the way) to display the results of calling the servlet. So, I got a 401 error on the servlet, looked through the log of my servlet and found the "Request could not be authenticated . . . jwt token with audience . . . is not issued" error, which led me to this blog - https://blogs.sap.com/2020/09/03/outdated-sap_jwt_trust_acl .
I have created a xs-security.json file in both the multi target app and the java servlet with the scope grant and so forth. Unfortunately, I am still receiving the same 401 error. Please provide guidance when you have a moment. Attached are a screenshot of the error from the log, the xs-security file from the multi target app (mtatest) and the xs-security file from the java servlet (userinfo).
xs-security.json of mtatest:
<code>{ "xsappname": "mtatest", "tenant-mode": "dedicated", "description": "Security profile of called application", "authorities":["$XSAPPNAME(application,userinfo).Display"], "scopes": [ { "name": "uaa.user", "description": "UAA" } ], "role-templates": [ { "name": "Token_Exchange", "description": "UAA", "scope-references": [ "uaa.user" ] } ] }
xs-security.json of userinfo:
<code>{ "xsappname": "userinfo", "tenant-mode": "shared", "scopes": [ { "name": "$XSAPPNAME.Display", "description": "display", "grant-as-authority-to-apps" : [ "$XSAPPNAME(application, mtatest)"] } ], "role-templates": [ { "name": "Viewer", "description": "Required to view things in your solution", "scope-references" : [ "$XSAPPNAME.Display" ] } ] }