Using Intellij to Build War and Deploy to Tomcat
Checklist of things you can do to verify where things go wrong:
- Manually build the artifacts using Build > Build artifacts.
- Verify if the artifact is in the expected output directory (out/artifacts/xxx).
- If not, go to File > Project structure > Artifacts
- Select the artifact file in question (project_name in this case).
- Verify if the output directory is correct. Optionally try to create this directory yourselves in case IntelliJ doesn't do it (although this would surprise me)
- Verify if the contents are correct.
- Optionally check "Build on make" to always have the latest version of your code deployed whenever you run the server.
Note that for deploying WAR files to a Tomcat, you should prefer to use the exploded WAR. This makes deploying/testing/debugging significantly faster.
I got this error when I tried to launch an app by using Run. The problem was that for some reason the WAR file wasn't deployed even after selecting Build->Build Artifacts. Solution: I closed Idea then reimported the project and choose as artifact war-exploded. This time the deploy worked.