Hi,
my project structure looks like
myproject
- common
- dao
- webmvc
- webapp <-- actual webapp, depends on the other sub projects
The settings.gradle of “myproject” contains an include of all the sub projects.
“webapp” is the project I want to run/deploy to Tomcat. It depends on the other subprojects: common, dao and webmvc.
Gradle does not show any errors. I can run the war
task and I get a war file that looks fine to me, including web.xml. The WAR file includes all the dependencies in WEB-INF/lib as expected.
But when I run “webapp” project in Eclipse (2025-03) on my Tomcat 10.1, I cannot open the web application in my browser. At the first attempt to navigate to it, a ClassNotFoundException
is logged for the servlet located in webmvc
dependency JAR. Tomcat says “Marking servlet [SimpleServlet] as unavailable”. All subsequent access attempts lead to 404.
Only classes directly in “webapp” are found. Classes from the dependencies are not found.
Even more weird: If I run
dir C:\eclipse\myworkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\webapp\WEB-INF\lib\*
which is the folder that Eclipse WTP seems to use as “webapps” folder for Tomcat, I see all the JARs and these contain the classes that Tomcat cannot find…
I’ve included ‘eclipse-wtp’ and ‘war’ plugins in the build.gradle of all (sub) projects.
The build.gradle file of “webapp” looks like this:
plugins {
id 'eclipse-wtp'
id 'war'
}
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api
compileOnly group: 'jakarta.servlet', name: 'jakarta.servlet-api', version: '6.0.0'
implementation project(':common')
implementation project(':dao')
implementation project(':webmvc')
}
java {
sourceCompatibility = JavaVersion.VERSION_17
}
compileJava {
options.release = 17
options.encoding = "UTF-8"
}
compileTestJava {
options.release = 17
options.encoding = "UTF-8"
}
testing {
suites {
test {
useJUnitJupiter()
}
}
}
eclipse {
wtp {
facet {
facet name: "jst.web", version: "6.0" // 5.0 doesn't help either
}
}
}
war {
webAppDirectory = file('src/main/webapp')
}
Any advice?