Chris Williams
Chris Williams

Reputation: 12481

Eclipse stopped building my WAR file after some Maven pom.xml changes

I recently took the opportunity to refactor our pom.xml file to use more filtering and get rid of some duplicated properties files. The build works fine now from the command line and in our CI environment, it is able to build a WAR and Jenkins deploys it without a problem.

Eclipse is another story, though. I work with Build Automatically checked and have Eclipse run Tomcat for me. On most code changes, Eclipse detects the change, builds the code and a new WAR file, and publishes the new WAR to Tomcat. After all of these Maven changes, it's no longer doing that. I'm not sure if the problem is that I right-clicked on the pom file a few times and selected manual Maven clean and installs and that somehow confused Eclipse but I can't get it back to the point where Eclipse knows how to build a WAR file for me and deploy it.

I'm going to assume my pom.xml file isn't the issue and not post it here since a manual build (mvn clean install) produces a WAR file in the target directory and our build on CI works fine without any changes. Multiple maven clean commands and Project -> Clean in Eclipse have been run with no help.

I don't see anything in the Eclipse logs from Window -> View -> General -> Error Log.

I've read a bunch of suggestions on StackOverflow and a lot of responses indicate that Eclipse's support for Maven sucks. I don't necessarily need Maven builds working here. I need Eclipse to build the code and then generate a WAR and realize it needs to be deployed to the Tomcat instance it's already running. Other than quitting Eclipse forever and paying for IntelliJ, is there a way to get this working again?

-- edit -- In case this helps. I stopped Tomcat and Eclipse, mvn clean from the command line, verified the target directory was removed, started Eclipse, turned on Build Automatically and now this is what I see in the target directory:

$ cd target
$ ls -la *
classes:
total 40
drwxr-xr-x  7 chris  staff   238 Oct 22 16:49 .
drwxr-xr-x  5 chris  staff   170 Oct 22 16:49 ..
-rw-r--r--  1 chris  staff  1088 Oct 22 16:49 application.properties
-rw-r--r--  1 chris  staff   727 Oct 22 16:49 deviceEnrollment.vm
-rw-r--r--  1 chris  staff    31 Oct 22 16:49 hibernate.properties
-rw-r--r--  1 chris  staff  1061 Oct 22 16:49 log4j2.xml
-rw-r--r--  1 chris  staff   354 Oct 22 16:49 portalEnrollment.vm

m2e-wtp:
total 0
drwxr-xr-x  3 chris  staff  102 Oct 22 16:49 .
drwxr-xr-x  5 chris  staff  170 Oct 22 16:49 ..
drwxr-xr-x  3 chris  staff  102 Oct 22 16:49 web-resources

test-classes:
total 16
drwxr-xr-x  4 chris  staff   136 Oct 22 16:49 .
drwxr-xr-x  5 chris  staff   170 Oct 22 16:49 ..
-rw-r--r--  1 chris  staff  1103 Oct 22 16:49 application.properties
-rw-r--r--  1 chris  staff    44 Oct 22 16:49 temp.txt

Upvotes: 3

Views: 966

Answers (3)

Elias
Elias

Reputation: 694

In my case I have deleted the war file under the server in server panel of eclispe and then right click on the project and hit run on server again than war file generated again.

Upvotes: 0

Chris Williams
Chris Williams

Reputation: 12481

Turns out something about building with Maven through Eclipse created a new run configuration both under "Apache Tomcat" and "Maven Build". After I deleted those two run configurations, everything started working again.

Upvotes: 0

Fred Bricon
Fred Bricon

Reputation: 5589

Try Maven > Update project (Alt+F5) and uncheck clean build

Upvotes: 1

Related Questions