Plugin web resources are loaded but empty on JIRA server

Hello,
I am developing a custom plugin and it works fine when I run it locally. All web resources are loaded.
But when I upload the plugin jar or obr file to my jira test server, I got this error from the browser Uncaught ReferenceError: toggleComponent is not defined, where toggleComponent is one of the function in my js file. When I checked the web resources e.g: js,css files are empty.

Here is how I define the web resources at the atlassian-plugin.xml:

<web-resource key="change-documentation-console-resources" name="Change Documentation Web Resources">
  <dependency>com.atlassian.auiplugin:ajs</dependency>
  <resource type="download" name="change-documentation-console.css" location="/css/change-documentation-console.css"/>  
  <resource type="download" name="change-documentation-console.js" location="/js/change-documentation-console.js"/>
  <resource type="download" name="images/" location="/images"/>  
  <context>change-documentation-console</context>
</web-resource>

So far I tried:

  1. Removing the / at the beginning of the web resource location. Result: web resources are still empty

  2. Adding <context>atl.general</context> and <context>atl.admin</context> while removing $webResourceManager.requireResource("org.autosar.jira.plugins.change-documentation-console:change-documentation-console-resources") Result: web resources are not loaded at all

  3. Adding alert() function to check if it will be executed. Result: alert() is not executed, because js file is empty.

AJS.$(document).ready(function() {
alert(‘JS Controller is loaded’);
});

I’m running out of ideas. Any help is much appreciated.
Thanks!

Can you try it out with a single word for the context, like maybe <context>cdc<context> ?
And then add this line in the <head> tag of your template $webResourceManager.requireResourcesForContext("cdc")

Hi Taylan,

thanks for the answer. However, changing the context to a single word and adding $webResourceManager.requireResourcesForContext("cdc") to my .vm template still doesn’t solve the issue. The web resources are not loaded at all in this case.

Do you maybe have any other ideas?

I am sorry to hear that. Do you maybe have multiple web resources? If yes, are they named the same?

the only web resources I have are the one I mentioned in the question.

  <resource type="download" name="change-documentation-console.css" location="/css/change-documentation-console.css"/>  
  <resource type="download" name="change-documentation-console.js" location="/js/change-documentation-console.js"/>
  <resource type="download" name="images/" location="/images"/> 

Do you think I should not use the same name for the css and js file?

That is fine. I was asking if you have multiple <web-resource> s with the same name in your atlassian-plugin.xml.
Like this:

    <web-resource key="some-resources" name="some Web Resources">
        <dependency>com.atlassian.auiplugin:ajs</dependency>
        <resource type="download" name="some.css" location="/css/some.css"/>
        <resource type="download" name="some.js" location="path/some.js"/>
        <resource type="download" name="images/" location="/images"/>
        <context>some</context>
    </web-resource>

        <web-resource key="some-resources" name="some Web Resources">
        <dependency>com.atlassian.auiplugin:ajs</dependency>
        <resource type="download" name="some.css" location="/css/some.css"/>
        <resource type="download" name="some.js" location="path/some.js"/>
        <resource type="download" name="images/" location="/images"/>
        <context>some</context>
    </web-resource>

If that is the case, give them different keys, names and contexts

Hi @Atika, can you check if the js/change-documentation-console.js file is located under the resources directory?

E.g.:

your-plugin-root
 - src
    - main
      - resources
        - js
          - change-documentation-console.js

You can also try checking if the plugin and your web-resource modules are enabled.

  1. Go to the admin panel of a product.
  2. Select the “Manage Apps” link.
  3. If your plugin is not visible on the list, click on the dropdown with the “User-installed” label and select "All apps:
  4. Check if the plugin is listed there and ensure it’s enabled.
  5. Now, expand the plugin and click on the “X of X modules enabled”.
  6. In the modules list, you can locate the key and/or name of the web-resource module.
  7. Ensure that the web-resource module is and it’s enabled.

Thanks,
Maciej Adamczak
Atlassian Developer

1 Like

@Taylan Ok understand, I only have 1 web resource.

Hi @madamczak yes the js file is located exactly as your example. I follow through the steps you gave to check if the modules are enabled and the web resources module is there and enabled.

From the browser’s dev tool network, I can see that the css and js files are loaded but the js file only contains

;
/* module-key = ‘my.company.jira.plugins.change-documentation-console:change-documentation-console-resources’, location = ‘/js/change-documentation-console.js’ */
;

I also discovered 2 error messages in the browser’s dev tool console:

  1. Source-Map-Fehler: Error: request failed with status 404 Ressourcen-Adresse: https://myjiratesthost/s/0b1d0fa903b414ec4630aa59b672b611-CDN/c37u7n/805004/6411e0087192541a09d88223fb51a6a0/4922173a3b2c57ac829aba90a3f84855/_/download/contextbatch/js/atl.general,jira.global,jira.general,-_super/batch.js?agile_global_admin_condition=true&baseurl-check-resources=true&healthcheck-resources=true&jag=true&jaguser=true&locale=en-US Source-Map-Adresse: aui.chunk.97b0b8778b1dab612048--f0ebc3ce920a8bb3519d.js.map;

  2. Source-Map-Fehler: Error: request failed with status 404 Ressourcen-Adresse: https://myjiratesthost/s/957542820b95bcd5d196bf9bfb3ad334-CDN/c37u7n/805004/6411e0087192541a09d88223fb51a6a0/937431062150c224b446b9c80561302d/_/download/contextbatch/js/_super/batch.js?locale=en-US Source-Map-Adresse: aui.chunk.6880542ee9d1db428d90--3d4584a88af3f8040a6a.js.map;

It seems like the batch js files can’t be found. Is this maybe related to my issue?

Do you have CDN setup for your Jira instance?

Could you try going to the Jira dashboard and pressing “B”, in order to try and disable the batch mode?

Let us know if the problem still exists in development mode.

1 Like

Hi @tjoy, No I don’t have a CDN set up for my Jira test instance. Also, can you elaborate more on the step of disabling the batch mode? What do you mean by pressing “B” on Jira dashboard?

Thanks

Is your Jira Instance running on a MS Azure server?

In development mode, you can use the keyboard shortcut “b” to disable resource batching and load resources individually.
Currently it looks like the error has something to do with batch files not being found (404)

Hi @tjoy,

I don’t have this issue on the development mode. I am able to run the plugin successfully on the development mode. I only encounter this issue when I deploy my plugin on the remote JIRA server.

Thanks

Hi all,

after some time digging, I found out the reason for this issue is that there were some part of my code which are not accepted by the js minifier that leads to syntax errors when deploying to the server. After rewriting this part of code, the js file is now loaded and not empty.
Thanks everyone for the support. I will therefore mark this as solution.

2 Likes