I have been trying to host Spring Boot application on WebSphere server.
Versions :
The app was successfuly deployed on standalone Tomcat 9.0.22 and webjars could be resolved there. However for WebSphere I receive an error when trying to access webjars from html
page :
2019-08-05 10:43:11.839 DEBUG 1 --- [ecutor-thread-6] o.s.web.servlet.DispatcherServlet : GET "/appcontext/webjars/jquery/jquery.min.js", parameters={}
2019-08-05 10:43:11.845 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/webjars/"]
2019-08-05 10:43:11.849 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2019-08-05 10:43:11.849 DEBUG 1 --- [ecutor-thread-6] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
And the webjars
pattern was successfuly mapped by Spring :
2019-08-05 10:43:09.039 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.handler.SimpleUrlHandlerMapping : Patterns [/webjars/**, /**] in 'resourceHandlerMapping'
The solution for this is to add classloading
entry, with useJarUrls
attribute set to true
, to WebSphere server.xml
file :
<server description="myServer">
<featureManager>
<feature>servlet-3.0</feature>
</featureManager>
<classloading useJarUrls="true"/> <!-- this line was added -->
<httpEndpoint httpPort="9080" httpsPort="9443" host="*" id="defaultHttpEndpoint"/>
</server>
This IBM support issue
was particulary helpful in solving this problem.