webapp location works differently from v0.10.0 to v1.1.1 breaking asset loading

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

webapp location works differently from v0.10.0 to v1.1.1 breaking asset loading

arnaldop
I have the following bundle:
{
	"bundle": "scrollingtable",
	"dependencies": [
		"jquery"
	],
	"assets": [
		{
			"name": "scrollingtable",
			"version": "1.0",
			"type": "js",
			"locations": {
				"webapp": "/js/scrollingtable.js"
			}
		}
	]
}
I get an error on page load because the JS file cannot be found.

The problem lies in WebappLocator.doGetContent().

I'm running a Spring Boot application as a Run profile from within Eclipse. Line 86 returns
"file:/Development/personal/spyclub/src/main/webapp/"
 which only contains an empty WEB-INF. Everything else is in the parent directory.

I tried changing the location line to:
"webapp": "../resources/static/js/scrollingtable.js"

But this gave me an IllegalArgumentException (The resource path [..] is not valid).

My understanding of the webapp location was that, if I appended the location to my URL in the browser, it should load. In other words, the asset should be loaded via a URL.

This is the way it used to be, utilizing ResourceUtils.getContentFromUrl, which is still in the codebase.

Since running an application from the command line using Maven, or from within Eclipse, or running some Main class somewhere, could give me completely different paths to my resources, I'd expect that the webapp location would be URL driven.

So I guess my question is, if webapp is not URL driven, how can I load a JS file that does not reside in the directory provided by ServletContext sc = request.getServletContext()?

Thanks for version 1.1! I'm upgrading from 0.10.0 and everything seems better, from the code, to the usage, to the documentation. Great job!!!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: webapp location works differently from v0.10.0 to v1.1.1 breaking asset loading

arnaldop
Or perhaps this use case would be covered by the locator "remote"?
Loading...