Maven Problem (Id can not be null)

Working with Maven I came across a very weird issue. I attempted to build a new project, and received a Fatal Error: ID Can Not Be Null. Basically a Java.Lang.NullPointerException. I work in a corporate environment so I had an idea of which parent POM was having issues, but it didn’t quite click in my mind until about 5 minutes ago. After researching the net for the past few hours, I finally had my AHA! moment and decided to try it out. The solution to this problem is as follows:

Inside the POM.XML file for the project you are currently working with, you should have something like the following:

<parent>
<groupId>com.mycompany.or.something</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<relativePath>../../parent/</relativePath>
</parent>
The groupId tag is very important, as in my case this is where the problem existed. I navigated to the local maven repo (~.m2/repositories) and through the directories til I came to the following dir:
~m2/repositories/com/mycompany/or/something/parent/1.0/
Inside this directory was a parent pom file. I opened it up in Notepad++ and looked through the tags. Sure enough, the repositories tag did not contain an ID element. I simply added one in ( <id /> ) and voila, problem solved.
Hope this helps someone in the future, because it had me banging my head against everything I could possibly find – from walls to staplers to windows (oh my!)

Comments are closed.