Try as I might I cannot get my Grails 7.0.0-M5 app...
# questions
j
Try as I might I cannot get my Grails 7.0.0-M5 app to start up with an embedded Undertow server - it always starts up with Tomcat. What am I overlooking? This is the relevant section from build.gradle: implementation "org.apache.grails:grails-core" //implementation "org.springframework.boot:spring-boot-starter-tomcat" implementation "org.springframework.boot:spring-boot-autoconfigure" implementation "org.springframework.boot:spring-boot-starter" implementation "org.springframework.boot:spring-boot-starter-actuator" implementation "org.springframework.boot:spring-boot-starter-logging" implementation "org.springframework.boot:spring-boot-starter-undertow" implementation "org.springframework.boot:spring-boot-starter-validation" I have commented out the Tomcat dependency and added Undertow, but still it uses Tomcat 10.
s
The likely answer is that something is pulling in tomcat transitively. Use gradle's dependency insights to try and figure out what it is that's pulling it in and add an exclusion clause to that dependency.
j
Will do. It's not a major problem, in fact, as I could just as well use Tomcat, but it was a bit of a puzzle.
s
Absolutely. I think if you want to use Undertow (We always did here) then it should be possible. Hopefully it is just as simple as an accidental exported dep in one of the other starters.
j
Not entirely sure how to determine what is bringing it in. './gradlew dependencies' results in an output showing 'org.apache.tomcat.embed' in a number of places, e.g: \--- org.springframework.boot:spring-boot-starter-websocket -> 3.5.3 +--- org.springframework.bootspring boot starter web3.5.3 | +--- org.springframework.bootspring boot starter3.5.3 (*) | +--- org.springframework.bootspring boot starter json3.5.3 | | +--- org.springframework.bootspring boot starter3.5.3 (*) | | +--- org.springframeworkspring web6.2.8 (*) | | +--- com.fasterxml.jackson.corejackson databind2.19.1 | | | +--- com.fasterxml.jackson.corejackson annotations2.19.1 | | | | \--- com.fasterxml.jacksonjackson bom2.19.1 (*) | | | +--- com.fasterxml.jackson.corejackson core2.19.1 | | | | \--- com.fasterxml.jacksonjackson bom2.19.1 (*) | | | \--- com.fasterxml.jacksonjackson bom2.19.1 (*) | | +--- com.fasterxml.jackson.datatypejackson datatype jdk82.19.1 | | | +--- com.fasterxml.jackson.corejackson core2.19.1 (*) | | | +--- com.fasterxml.jackson.corejackson databind2.19.1 (*) | | | \--- com.fasterxml.jacksonjackson bom2.19.1 (*) | | +--- com.fasterxml.jackson.datatypejackson datatype jsr3102.19.1 | | | +--- com.fasterxml.jackson.corejackson annotations2.19.1 (*) | | | +--- com.fasterxml.jackson.corejackson core2.19.1 (*) | | | +--- com.fasterxml.jackson.corejackson databind2.19.1 (*) | | | \--- com.fasterxml.jacksonjackson bom2.19.1 (*) | | \--- com.fasterxml.jackson.modulejackson module parameter names2.19.1 | | +--- com.fasterxml.jackson.corejackson core2.19.1 (*) | | +--- com.fasterxml.jackson.corejackson databind2.19.1 (*) | | \--- com.fasterxml.jacksonjackson bom2.19.1 (*) | +--- org.springframework.bootspring boot starter tomcat3.5.3 | | +--- jakarta.annotationjakarta.annotation api2.1.1 | | +--- org.apache.tomcat.embedtomcat embed core10.1.42 | | +--- org.apache.tomcat.embedtomcat embed el10.1.42 | | \--- org.apache.tomcat.embedtomcat embed websocket10.1.42 | | \--- org.apache.tomcat.embedtomcat embed core10.1.42 | +--- org.springframeworkspring web6.2.8 (*) | \--- org.springframeworkspring webmvc6.2.8 (*) +--- org.springframeworkspring messaging6.2.8 | +--- org.springframeworkspring beans6.2.8 (*) | \--- org.springframeworkspring core6.2.8 (*) \--- org.springframeworkspring websocket6.2.8 +--- org.springframeworkspring context6.2.8 (*) +--- org.springframeworkspring core6.2.8 (*) \--- org.springframeworkspring web6.2.8 (*)
s
The problem looks like
org.springframework.boot:spring-boot-starter-web
pulls in
org.springframework.boot:spring-boot-starter-tomcat
Which is pulled in by
org.springframework.boot:spring-boot-starter-websocket
So if you need the websocket starter try adding an entry directly for
org.springframework.boot:spring-boot-starter-web
and add the exclusion on the tomcat starter.
SO even though you don't explicitly use the tomcat starter it's pulled in (eventuallly) by the websocket starter.
j
Not entirely sure what you mean here but I'm interpreting it as having this: implementation("org.springframework.boot:spring-boot-starter-web") { exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat" } I did that and it still starts up with Tomcat. Is the order in which the dependencies are listed significant for this?
j
Curiously, I read that very article a short while ago, followed what it said and still ended up with Tomcat instead of Undertow.
g
@John Moore For me, I have to totally remove tomcat dependency jar, then it worked, My app is 6 though. I am using Jetty
j
How you totally remove the Tomcat dependency jar?
g
In build.gradle. these are the changes
I believe there is a redundant runtimeonly jetty dependency there in the ss
Fnd out all your jars with spring-boot-starter-tomcat and exclude it