Thanks for your reply Martin. xdocs folder is at src/main/webapp/xdocs
I did some debugging and also turned on debug logging, which reveals the complete resource location process for HTML and CSS files. Also dumped the list of ResourceFinders in the log and that looked just fine. Could not find the cause of the problem yet. There is a lot more to fix because of the upgrade to Wicket 9 so I will return to this problem later. I moved the xdocs folder to the location of the class for now. regards, Peter > Op 20 sep. 2021, om 10:45 heeft Martin Grigorov <mgrigo...@apache.org> het > volgende geschreven: > > Hi, > > On Mon, Sep 20, 2021 at 11:26 AM Peter van der Post < > peter.van.der.p...@gmail.com <mailto:peter.van.der.p...@gmail.com>> wrote: > >> I’m in the process of upgrading an application to Wicket 9 in order to get >> strict CSP compliance. >> >> I’m using >> >> response.render(CssHeaderItem.forReference(new >> CssResourceReference(MyClass.class, “file.css", getLocale(), "screen", >> ""))); >> >> to have Wicket provide the proper reference to the CSS file. This works >> fine, as long as the CSS file is next to the Java/HTML source files. >> But I want to keep the projects file structure with the CSS files in de >> xdocs/css folder. >> > > Where exactly in your project is xdocs folder ? > It should be at src/main/webapp/xdocs (if you use Maven to package your > app). > > >> I’m trying to accomplish this by adding its path with >> >> getResourceSettings().getResourceFinders().add(new >> WebApplicationPath(getServletContext(), "xdocs/css")); >> >> This does not give me an error, but loading the CSS file fail in the >> constructor of CssResourceReference(): > > >> ResourceReferenceRegistry:### - A ResourceReference wont be >> created for a resource with key [scope: ###; name: file.css; locale: null; >> style: null; variation: null] because it cannot be located. >> >> What am I missing here? I suppose the CssResourceReference class should be >> using the ResourceFinders that have been set up? >> > > Right! > org.apache.wicket.core.util.resource.locator.ResourceStreamLocator#locate(java.lang.Class<?>, > java.lang.String) uses the configured finders. > Put a breakpoint at > org.apache.wicket.core.util.file.WebApplicationPath#find() and see why it > is not found. > > >> >> Many thanks in advance, >> Peter