Hi Tim, thanks for the response and the explanation on the webapp directories. I always have to go back and reference that.
I have some good news as well... It's finally working.
The link below has a good example for the embedded Tomcat, and they provide a download of the project files. Although, I had to switch back to JDK 8 for the example, as I was getting a 404 error when doing the 'mvn clean package' using JDK 13.
So then I switched back to my own application, and after making some adjustments it's now serving the index.html page.
Here's what I adjusted:
- Added the directory and targetPath values to the POM
- Copied the Main method contents from the example, with the addition of the 'tomcat.getConnector()' line as mentioned in one of the earlier comments.
+ After some experimenting, the key was setting the appBase with the function 'tomcat.getHost().setAppBase(appBase)'. Also, I had to change the 'tomcat.addContext' function to 'tomcat.addWebapp(contextPath, appBase)'.
- Added the function 'tomcat.getConnector()' that James mentioned ealier in the thread (for Tomcat 9).
Interestingly, it doesn't seem to matter where appBase is set, as long as the folder exists. In the code it's set to '.', but I also tried 'C:/' and 'C:/dev' and it worked just fine.
What's still bugging me is that I don't know how to use 'tomcat.addContext(..., ...)'. It seems like one should be able to use that to serve up a static file. I can almost die happy, but I guess I'll let that go for right now. Perhaps it will become clear a bit further down the road.
Here are the pom and app files in all their glory: