-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I configure embedded Jetty to serve webjars? #12128
Comments
Update: It appears that if you have a |
@kshep92 I'm not exactly sure what you are trying to achieve with: resourceHandler.setBaseResource(ResourceFactory.of(webJarsContext).newClassLoaderResource("META-INF/resources/webjars/", true)); That is looking through all the jars on your class path for any that contain a "META-INF/resources/webjars/" directory and making that the docroot of your context. Is that what you intend? i.e. you want static content to be served from your classpath? Oh I think I see a bug in |
I believe that is how WebJars are supposed to work, but I am open for correction if this is not the correct way to go about this. |
@kshep92 for this conversation, you are the webjars expert! So if you are expecting |
Thank you very much. |
Fix #12104 by returning a CombinedResource for a ClassLoader resource that has multiple directory matches.
@gregw awesome! I'll check it out. |
Here's a few real world examples of webjars ...
In these examples, none of those belong in a Java Classloader. |
@kshep92 the PR by @gregw makes the Resource lookup use an internal CombinedResource instead of first found. The If you are using embedded Jetty and using something other than You can find an example of that here -> https://github.com/jetty/jetty-examples/blob/12.0.x/embedded/ee10-metainf-resources/src/main/java/examples/MetaInfResourceDemo.java |
@joakime Ok that clears it up. Thanks for the example as well. |
Jetty Version
12.0.10
Jetty Environment
ee10
Java Version
17
Question
I'm attempting to serve WebJars using embedded Jetty with the following configuration:
I've included Bootstrap as a WebJar dependency in my Gradle file:
implementation("org.webjars:bootstrap:5.2.3")
However, when I visit
/webjars/bootstrap/5.2.3/css/bootstrap.css
I get a 404. However, If I put a file in my project'ssrc/main/resources/META-INF/resources/webjars
directory, it gets served.What is wrong with my configuration?
The text was updated successfully, but these errors were encountered: