cancel
Showing results for 
Search instead for 
Did you mean: 

where's the resources/sap-ui-core.js?

Former Member
0 Kudos

hi Guys,

I'm a starter of SAP UI5. I created a ui5 project using the eclipse project wizard.

In the index.html file, there's the bootstrap in the red box:

My question is: where's this resources folder? I looked all over the project structure, I didn't find a clue.

Could you tell me how does this line of code links to the sap-ui-core.js in detail?

Thanks !!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi there,

is this a local project?

The path "src=''resources/sap-ui-core.js" means that the file sap-ui-core.js is in the directory resources RELATIVE to the file (usually index.html) where you include it.

That means if your project folder is

c:\projects\project1\

the file sap-ui-core.js should be located in the folder

c:\projecty\project1\resources\

So you can either copy the sapui5 framwork there, or you change the path accordingly to the location of the framework.

Greets,

ben

cmetz
Participant
0 Kudos

Thanks for your reply Ben.

I just checked my project folder, but i couldn't find this file nor the resource folder:

I also searched my computer for this file and i only found this 2 locations:

(1) H:\Documents\workspace\.metadata\.plugins\org.eclipse.wst.jsdt.core\sapui5\sap.ui.core.js

(2) C:\Program Files (x86)\eclipse\configuration\org.eclipse.osgi\bundles\1246\1\.cp\libraries\sap.ui.core.js

But there was also one strange address:

http://localhost:49772/ZUI5_LIEF_APP/resources/sap-ui-core.js

This seems to be the right one. At least there is resource folder, but i cant access it.

Any ideas?

Regards Chris

Former Member
0 Kudos

HI Chris,

Are you looking for -

And if you want to search this file in your local system then it must be available under ur

\workspace\.metadata\.plugins\org.eclipse.wst.jsdt.core\sapui5\sap.ui.core.js

Hope this helps you!!!

Regards,

Deepali

cmetz
Participant
0 Kudos

Thanks Deepali for your answer. Yes that the file i was looking for, I also found it, but thats not solving my problem.

I want to know how this file is connected with the bootstrap "resources/sap-ui-core.js". There is no resource folder at all! It has to be linked somehow, but where and how?

Background:

I am trying to understand this article:

https://help.sap.com/saphelp_nw74/helpdata/en/9c/5a9619f69f4a819f91fc89d9ff56f1/content.htm?frameset...

Its about how to register resources in different locations.

It says:

"The component and all its resources, the components, views, controllers, controls, css files, JavaScript modules, and so on, can be located in different locations (paths and web applications) and not directly under the default application root, for example index.html. By default, SAPUI5 tries to load the resources relative to the location where thesap-ui-core.jsbootstrap is located.

But where is thissap-ui-core.jslocated???

Regards

Chris

Former Member
0 Kudos

Hi Christoph,

sorry, I don't really understand you issue...

the sap-ui-core.js could be located everywhere - It could be, for example, on your local machine, on your AWS instance or you load it directly from https://openui5.hana.ondemand.com/resources/sap-ui-core.js

- you decide from where you want to load it.

I'm interested in what's your setup - do you use AWS or the SAP HANA Cloud trial? Or do you develop only locally?

Greets,

ben

cmetz
Participant
0 Kudos

Hi Ben,

i am developing locally.

In the bootstrap I declare with "src=resources/sap-ui-core.js" a JavaScript file. I just want to know how this concept is working and how the system is accessing this file, because I cant find a resource folder either on my local machine nor in Eclipse.

I hope you can now understand my issue.

Regards

Chris

Former Member
0 Kudos

Hi Chris,

if you are develop locally, you have to download SAPUI5 / OPENUI5 on you own and put it to the desired location. Usually, the framework is located in the resource folder which is located in your project folder.

Download OPENUI5 here:

OpenUI5 - Download

When you extract it, you can see it contains the resource folder. Move this resource folder to your project location, and you are set.

Hope this helps!

cmetz
Participant
0 Kudos

Hey Ben

first of all thanks for your effort ;-).

We are coming closer, but thats still not what i wanted to know. I don't want to know how to setup the environment, I did that already and everything is working fine (Eclispe->Help->Install New Software).

I didn't copy the resource folder to my project location, so I have no resource folder and its still working. And thats what I cant understand.

I have basically the same question like Aaron Shen, who created this topic:

"My question is: where's this resources folder? I looked all over the project structure, I didn't find a clue.

Could you tell me how does this line of code links to the sap-ui-core.js in detail?

Thanks !!"

Former Member
0 Kudos

Hi Christoph,

you are welcome, I'm also interested in what's going up over there

Could you explain your local development environment?

I've only worked with the SAP Hana Studio connected to an repository which is located on an AWS Server, and I'm interested in how you develop locally. For example, what webserver are you using?

FYI:

If you want to know from here the sap-ui-core.js is loaded, you can use firefox or chrome console and under "Network" you can see it there...

Thanks,

ben

cmetz
Participant
0 Kudos

The file is loaded from this location:

http://localhost:53755/ZUI5_LIEF_APP2/resources/sap-ui-core.js

To execute the project I just say: Run As->Web App Preview.

I didnt install a webserver on my own, i guess the appropriate environment came with the installation of UI5.

But the files from the localhost have to be stored and linked as well? Argghhhhh I suspect I won't get this quiz solved 😞

Former Member
0 Kudos

Did you use any guide to set up your local environment? If so, can you give me a link plz?

As far as I know UI5 doesn't come with a webserver, so we should clarify how this is working

kammaje_cis
Active Contributor
0 Kudos

Someone asked my question.

I think I figured it. May be use full to you.

Check the web.xml file inside WebContent->WEB-INF

- There is a a mapping for '/resources' path, pointing to a servlet, called 'ResourceServlet'.

- In the same file, this servlet points to a Servlet Class ''com.sap.ui5.resource.ResourceServlet"

Now this Servlet Class is available inside a jar file located here.

<Your Project> -> Java resources -> Libraries ->Web App Libraries->'com.sap.ui5.resource<your ui5 version>.jar

Since you are running 'Web App Preview', we are looking at 'Web App Libraries'.

I think the java code (from which the above jar was compiled) would have the code to point to the resources inside 'JavaScript Resources -> SAPUI5 Core Libraries'. I am not sure if we can see the java code here though.

regards

Krishna

honam_yu
Explorer
0 Kudos

I have the same question and I found this path.


sap-ui-core.js file we are looking for are included in com.sap.ui5.core_ of <version> .jar file. (There is the resources folder in this file)

com.sap.ui5.core_ of <version>.jar is included in eclipse> plugins(If you use hanastudio, hdbstudio> plugins)


I think pull path before resources is automatically found by ui5 framework(ResourceServlet).

servlet handle resource.


web.xml 

<!-- ============================================================== -->

<!-- UI5 resource servlet used to handle application resources      -->

<!-- ============================================================== -->

<servlet>

  <display-name>ResourceServlet</display-name>

  <servlet-name>ResourceServlet</servlet-name>

  <servlet-class>com.sap.ui5.resource.ResourceServlet</servlet-class>

</servlet>

ResourceServlet.class

public class ResourceServlet extends HttpServlet

{

  public static final String REQ_ATTR_RESOURCE_OVERLAY = new StringBuilder().append(ResourceServlet.class.getName()).append(".OVERLAY").toString();

  public static final String REQ_ATTR_CACHEBUSTER_REQUEST = new StringBuilder().append(ResourceServlet.class.getName()).append(".CACHEBUSTER").toString();

  public static final String REQ_ATTR_PATH = new StringBuilder().append(ResourceServlet.class.getName()).append(".PATH").toString();

  public static final String CTX_ATTR_CACHEBUSTER_TIMESTAMP = new StringBuilder().append(ResourceServlet.class.getName()).append(".CACHEBUSTER_TIMESTAMP").toString();

  private static final long serialVersionUID = -2721387829166070732L;

  private static final Logger LOG = Logger.getLogger(ResourceServlet.class.getName());

  private static final Pattern BOOTSTRAP_SCRIPT = Pattern.compile("\\/sap-ui-core(-dbg)?\\.js");

  private static Map<String, CacheResource> cache = new ConcurrentHashMap();

  private static long cachebusterTimestamp;

  private static long remoteCachebusterExpiration = 0L;

  private ResourceLocator locator = null;

  private Template template = null;

  private ResourceConfig config = null;

  public void init()

    throws ServletException

  {

    ServletContext context = getServletContext();

    this.locator = ResourceLocatorFactory.createResourceLocator(context);

    this.config = ResourceConfigFactory.createResourceConfig(context);

    this.template = new Template(this.locator, this.config.getTemplatePath());

    String timestamp = (String)getServletContext().getAttribute(CTX_ATTR_CACHEBUSTER_TIMESTAMP);

    if (timestamp == null) {

      Map properties = ResourceUtil.loadProperties(context);

      if (properties != null) {

        timestamp = (String)properties.get("x-sap-ui5-BuildTimestamp");

      } else {

        Manifest manifest = ResourceUtil.loadManifest(context);

        if (manifest != null) {

          timestamp = manifest.getMainAttributes().getValue("x-sap-ui5-BuildTimestamp");

        }

      }

      if ((timestamp == null) || (timestamp.isEmpty()) || (!CacheBusterUtil.isCacheBusterTimestamp(timestamp))) {

        LOG.warning("Could not find property \"x-sap-ui5-BuildTimestamp\" in ui5.properties or MANIFEST.MF or the value is not valid! Using System.currentTimeMillis as cachebuster timestamp.");

        timestamp = Long.toString(System.currentTimeMillis());

      }

      cachebusterTimestamp = CacheBusterUtil.getTimestamp(timestamp);

      getServletContext().setAttribute(CTX_ATTR_CACHEBUSTER_TIMESTAMP, timestamp);

    }

  }

private boolean handleBootstrapRequest(HttpServletRequest request, HttpServletResponse response)

    throws IOException

  {

    if ((isDevMode(request)) && (System.getProperty("wtp.deploy") != null))

    {

      Matcher m = BOOTSTRAP_SCRIPT.matcher(request.getPathInfo());

      if (m.matches())

      {

        String fileSuffix = m.group(1) == null ? "" : m.group(1);

        Resource bootstrapFile = null;

        if (request.getAttribute(REQ_ATTR_RESOURCE_OVERLAY) != null) {

          bootstrapFile = (Resource)request.getAttribute(REQ_ATTR_RESOURCE_OVERLAY);

        } else {

          bootstrapFile = this.locator.findResource(new StringBuilder().append("/resources/sap-ui-core").append(fileSuffix).append(".js").toString());

          if ((bootstrapFile == null) || ("REMOTE".equals(bootstrapFile.getProperty("source")))) {

            return false;

          }

        }

        Resource lessSupport = this.locator.findResource(new StringBuilder().append("/resources/sap/ui/core/plugin/LessSupport").append(fileSuffix).append(".js").toString());

        if ((bootstrapFile != null) && (lessSupport != null))

        {

          long identifier = Math.max(bootstrapFile.getLastModified(), lessSupport.getLastModified());

          File tempDir = new File(System.getProperty("java.io.tmpdir"));

          File tempBootstrap = new File(tempDir, new StringBuilder().append("sap-ui-core-less-").append(identifier).append(fileSuffix).append(".js").toString());

          ByteArrayOutputStream os = new ByteArrayOutputStream();

          if (!tempBootstrap.exists())

          {

            tempBootstrap.createNewFile();

            tempBootstrap.deleteOnExit();

            bootstrapFile.pipe(os);

            os.write("\ntry {\n".getBytes("UTF-8"));

            lessSupport.pipe(os);

            os.write("\n} catch (ex) { /* ignore the errors when defining the LessSupport */ };".getBytes("UTF-8"));

            OutputStream fileOs = new FileOutputStream(tempBootstrap);

            try

            {

              os.writeTo(fileOs);

            } finally {

              if (fileOs != null) {

                fileOs.close();

              }

            }

          }

          Resource resource = new ServletResource(getServletContext(), new StringBuilder().append(request.getServletPath()).append(request.getPathInfo()).toString(), tempBootstrap.toURI().toURL(), "MODIFIED");

          request.setAttribute(REQ_ATTR_RESOURCE_OVERLAY, resource);

        }

      }

    }

    return false;

  }

Former Member
0 Kudos

Hi Krishna,

just to add it here in case someone is looking for it too: You can find the openui5 version of the Resource Servlet here:

openui5/ResourceServlet.java at master · SAP/openui5 · GitHub

It goes through the deployed archive on the application server and hands the js files to the client as you said.

HTH,

M.

PS: Here is a link to the current version if the above master branch is not working somewhen in the future:

openui5/ResourceServlet.java at 5ecad53b87aa4dba74b18b1d86b0cf7948ab1258 · SAP/openui5 · GitHub

0 Kudos

Hi

Can we load the sap-ui-core.js from a custom folder inside which available our webapp folder?

eg: my sap-ui-core.js is in - webapp-> staticcorejs->sap-ui-core.js

Assume that the version I'm using in my app is removed in CDN.

Answers (4)

Answers (4)

JerryWang
Advisor
Advisor

Hi Aaron,

suppose you are running you application on tomcat,

you could observe the resource folder in Chrome Development tool ( F12 ) tab - Sources, and the sap-ui-core.js is just within that folder.

click on Network tab, and you will find how this js file is loaded from your local machine:

Best regards,

Jerry

dionisio_ambrona
Explorer
0 Kudos

Hi,

maybe also try to use "/sap/ui5/1/resources/sap-ui-core.js" instead.

cmetz
Participant
0 Kudos

Hey guys,

I have the same question and I am still not able to find the answer. We are not talking about how to integrate the bootstrip (resources/sap-ui-core.js) from a server, it has to be somewhere on the local machine and I should be able to access it somehow through eclipse. Where is the location of this file in Eclipse?

Can someone please explain how that is working?

Thanks and regards

Chris

ChandraMahajan
Active Contributor
0 Kudos

Hi Aaron,

Refer this thread discussion and

also refer sapui5 documentation on bootstrap Documentation/AdvancedTopics/Bootstrap – SAPUI5 Wiki (TIP CORE User Interface)

Regards,

Chandra