Source files are not being included in WAR
I've had this problem for the last couple of days where building and running tomcat through would result in the target directory/WAR to have a lot of missing files.
Basic Tomcat local run configuration:
- Make
- Build 'MyModule:war exploded' artifact
I couldn't determine any real patterns for the bug, but I did a lot of mvn clean's and invalidate/restarts and the problem seemed to bounce between 2 things. Either there were so many missing files that my app would not load and show a "view resolver error" (its a spring app, and this is a spring specific error message) or say template "someTemplateName.ftl" is missing. Other times, there would be enough files for the webapp to load the home page, but many of the js/css files required to display the page properly would be missing.
It occurs on every git branch that I check out. Most importantly, the problem still occurs when I checkout tags of previous versions of my app that I have deployed to production servers.
I just loaded up IntelliJ 15, ran mvn clean and then ran the same tomcat run configuration, and it worked perfectly.
Anyone else run into this issue?
Please sign in to leave a comment.
Does maven build the correct artifact from the command line?
Can you inspect artifacts generated by IDEA and notice any problems?
Try removing the automatically generated artifacts and reimport the project from Maven.
In case the issue persists, please report a bug at https://youtrack.jetbrains.com/issues/IDEA and provide a sample project to reproduce it.
I had another problem where IntelliJ was not executing a maven plugin that was bound to the "generate-sources" phase of the lifecycle. To solve this problem, I have changed my tomcat run configuration to perform these steps.
In the deployment tab, I deploy the "external source" folder located at target/Spring-1.0.0-SNAPSHOT, which is the exploded war file that maven has built.
"Does maven build the correct artifact from the command line?"
Yes, by following the above steps, the maven project is built correctly.
"Can you inspect artifacts generated by IDEA and notice any problems?"
I have been manually inspecting the exploded WAR in the target directory and found many missing files (more than 50% of files missing). The missing files did not seem to be consistent (different files were missing after a invalidate + restart).
"Try removing the automatically generated artifacts and reimport the project from Maven."
I removed the list of artifacts in (File | Project Structure | Artifacts). I assume these are the auto-generated artifacts you were referring to. How do I re-import the project from maven?
Delete .idea directory and open pom.xml to reimport.