Support WebJars directly in Jersey
See original GitHub issueThis is half question and half (potential) bug report. I’ve inquired about the problem in the webjars-locator project and was directed here.
I’m trying to get swagger-ui working in a version agnostic manner inside of Spring Boot with Jersey and Tomcat. According to the WebJars documentation, having a pom.xml similar to the following should allow me to access swagger-ui via http://localhost:8080/webjars/swagger-ui/ but it only works via http://localhost:8080/webjars/swagger-ui/3.6.1.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.32-1</version>
</dependency>
</dependencies>
Is there anything special I’d need to do to get webjars-locator working in this situation? It works just fine in spring-boot-starter-web which leads me to believe this is potentially a bug.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Config Swagger-ui with Jersey - java - Stack Overflow
I have my web service on Tomcat. I have been able to integrate the swagger with Jersey. To integrate swagger-ui , based on...
Read more >Jersey 2.25.1 User Guide - GitHub Pages
This is user guide for Jersey 2.25.1. We are trying to keep it up to date as we add new features. When reading...
Read more >Simple Java RESTful Web Service with Jersey — JAX-RS ...
First, you need to know how to direct all the REST requests that are coming from your REST client to direct towards your...
Read more >Build RESTful Service in Java using JAX-RS and Jersey ...
Java API for RESTful Web Services (JAX-RS), is a set if APIs to developer REST service. JAX-RS is part of the Java EE6,...
Read more >Developing RESTful Web Services with JAX-RS (Jersey)
Jersey RESTful Web Services framework is an open source, ... RESTful Web Services in Java that provides support for JAX-RS APIs and serves ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve managed to replicate some of the issue in a git repo. Instructions to reproduce are in the README.
I’ve done some analysis on this and would like to help fix.
As @philwebb mentioned the webjars functionality is getting implemented by
org.springframework.web.servlet.resource.WebJarsResourceResolver. Unfortunately this is in the spring-mvc project and leverages the ResourceResolver mechanism which isn’t available to spring-jersey users.I’ve dreamt up a couple of options
By all accounts a servlet 3.0 should serve static files in the
META-INF/resourcesdirectory. The webjars documentation explains as such. I just can’t get this to work. Tried adding in the Tomcat DefaultServlet and setting Jersey to be a Filter but no joy.Can someone steer me in the right direction?
While this feature would be useful to Jersey users, I think we can’t really address this properly in Spring Boot. Spring Framework supports WebJars in the context of the resource handling feature, supporting serving static resources, cache busting, HTTP cache headers, etc.
Spring Boot should auto-configure this feature, once it’s supported officially by Jersey. Closing this issue for now, we should reopen it once it’s available in Jersey.