Wednesday, June 4, 2014

netbeans "package does not exist" error -- maven considered harmful

upgraded to netbeans 8 and found a bunch of cryptic errors in my projects:
package XXXXX does not exist
in this case XXXXX was a package provided by another netbeans project. it does indeed exist, the jar is being built properly and compiling the "broken" project succeeds and the application runs. so this is purely a problem with netbeans parser / indexer. i tried removing the dependency and re-adding it, cleaning and rebuilding, and exiting netbeans, removing the cache and restarting. nothing helped

looking thru messages.log, i see
WARNING [org.netbeans.modules.java.source.indexing.JavaIndex]: Ignoring root with no ClassPath: /home/YYYYY/working/nq0/XXXXX/XXXXX.git/src
didn't find much mention of that warning on the interwebs. looking at the "project properties" page for the project i realized i'd seen this problem before and started fiddling

the problem is that buried in the XXXXX directory, there's a pom.xml. netbeans detects this and somehow modifies how the project is managed. it's a "project with existing sources", not a maven project. but somehow netbeans fails to honor that when it finds a pom.xml

my solution was to deactivate the maven plugin (why that gets installed in the first place is beyond me). which eliminates the issue (i reactivated it temporarily to verify that that was actually the problem). this happened when i upgraded to netbeans 7, and i'm sure this will happen again when i upgrade to 8

maven is terrible, and the plugin makes it worse. it's the wrong metaphor for managing dependencies

1 comment:

Mat Jaggard said...

THANK YOU!!

I already hate Maven and was starting to hate Netbeans too!