Hi, On Mon, Sep 20, 2021 at 11:26 AM Peter van der Post < 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