Getting Java.Lang Exception while trying to bundle my frontend resources using atlassian-webresource-webpack-plugin

I am learning to build app for server. I am using react for my front end code and bundling it using web pack. and atlassian-webresource-webpack-plugin. The files are generated properly within target folder. Also the related xml enteries are generated.
However when I try to require those resources using $webResourceManager.requireResourcesForContext(“pluginKey:context”)

I am getting
java.lang.RuntimeException: Cannot read resource …

exception.

I am not sure how to get this working.
I removed all my react code and just added simple javascript console but removed other webconfig also.

if you require from context, you should use just the context name, not the plugin key.

But I have the feeling the exception is unrelated, can you share more of the stack trace?

I was using plugin key to avoid conflicts with other vendors.
I tried with simple context also.
I understand it is not related to using pluginkey.

What I feel is that the plugin is trying to fetch resources from different location.
webpack config output is
output: {
path: path.resolve(MVN_OUTPUT_DIR, “js”),
filename: “[name].js”
},

MVN_OUTPUT points to target/classes directory

and in xml descriptor
location is
resource type=“download” name="[name].js" location="[name].js"/

so it would search in target/classes directory.
It should search in target/classes/js directory.

Try the following:

In webpack config for WRM plugin use

xmlDescriptors: path.resolve('./target/generated-resources/', 'META-INF', 'plugin-descriptors', 'wr-defs.xml'),

set output path path: path.resolve(’./target/generated-resources/’)

in pom.xml set

<resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
            </resource>
            <resource>
                <directory>${project.basedir}/target/generated-resources</directory>
            </resource>
        </resources>

Make sure you set

<Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>

in jira-maven-plugin config (spring scanner)

Is the wr-defs.xml generated correctly?

Then it should be able to find $webResourceManager.requireResourcesForContext(“contextName”) in velocity.

Thanks,
@ernst.stefan

I was targeting different folders for js, css and media.
I managed that by handling output file name in webpack keeping rest as I have mentioned before.

output: {
path: path.resolve(MVN_OUTPUT_DIR),
filename: “js/[name].js”
}

Your solution was similar to what had already configured.