Java maven how to create app with nested tomcat

I wonder if this is a somewhat awkward way of thinking, but I couldn't find any hint of internet in my idea. Maybe I just didn't phrased my question correctly, but somehow, this is what I would like to do:

I have a complex application written in java with spring and quartz and a whole set of dependencies. The application runs inside the apache tomcat servlet container. Now I know I can create a war file and deploy it to a productive server machine (after our internal ITs have installed and configured tomcat on that machine), but I would like to do it a little differently.

I want maven to build a prepackaged tomcat app server with all dependencies and configuration settings and my application. In fact, all that needs to be done on a production system is copy the package (or zip or tar.gz or whatever is needed) to the server, unzip it into a directory of mine or their choice, and run this local isolated cat. It will only run my application (which will still be loaded on the machine), and I could even go that far and deploy the second option to, say, another client in the directory next to the first. None of them could interfere with each other, even if they are using different versions with different dependencies.

Can this be done? Is this a desirable approach or am I on a completely wrong path here?

What I think would be helpful for this approach (even though with incompatible dependencies or settings between two or more different installations) is that I can push the entire package to our admins and they can just deploy it to the server without having to configure anything in tomcat after installing it, etc.

Any hints

+3


source to share


1 answer


Create Maven project as parent project (pom type). Include your webapp as a module project (war type). Create another module project, possibly "myapp-standalone" (jar type) and include Embeddable Tomcat as a dependency. Write a starter class to start internal Tomcat (see ATM / ΓΌberjar executable ). When creating the application, copy the generated jar war file into the Tomcats webapp directoy program.



In your launcher class you need to make sure the ports of the current Tomcat are not already in use.

+2


source







All Articles