According to the documentation here it says:
If you have a modified web.xml template then you will need to migrate this to Spring as Grails 3.x does not use a web.xml (although it is still possible to have on in src/main/webapp/WEB-INF/web.xml).
which I interpret to mean that if I'm incorporating a 3rd party proprietary library that has a web.xml
, then I can put it in src/main/webapp/WEB-INF
unaltered (along with everything else that they put in their tomcat webapp directory) and grails will load it. Is this interpretation correct? That's what seems to be implied by this answer.
I started a grails 3 app with the react
profile (I tried the web
profile too) and a webpage with calls their servlet. However, while an html file in webapp
can be found, the servlet call itself is returning 404
and I can't figure out why. If I build a war file and deploy on a standalone tomcat, the servlet call works, but when I run like this:
./gradlew server:bootRun --debug
then it doesn't, and I don't see anything interesting printed to the console.
Is there some URL mapping I need to manipulate or something in application.yml
?
In the web.xml, the servlet that's being called looks like this (this is a small piece of it, does it am):
<servlet>
<servlet-name>DataSourceLoader</servlet-name>
<servlet-class>com.isomorphic.servlet.DataSourceLoader</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DataSourceLoader</servlet-name>
<url-pattern>/isomorphic/DataSourceLoader</url-pattern>
</servlet-mapping>
I realize the alternative is to rewrite web.xml
using Beans and put stuff in resources.groovy
, but I'd prefer an approach that requires as little of my coding as possible.
[update]
I've been able to update my grails-app/conf/spring/resources.groovy
with this:
import org.springframework.boot.web.servlet.ServletRegistrationBean
// Place your Spring DSL code here
beans = {
DataSourceLoader(ServletRegistrationBean) { bean ->
servlet = new com.isomorphic.servlet.DataSourceLoader()
urlMappings = ['/isomorphic/DataSourceLoader']
}
}
and it seems to be working... Nevertheless, I am still interested in ways to only use web.xml
, if possible, which is my original question.