maven "cannot find symbol" message unhelpful

mattg picture mattg · Jan 4, 2013 · Viewed 156.4k times · Source

This is a really simple question, and it's probably a setting somewhere I don't know about, but Google is being particularly unhelpful for this question, giving results about compilation errors, not how to change compilation error messages.

When I build my project with maven, it will give me error messages formatted roughly as follows:

[ERROR] /path/to/source/Main.java:[13,8] error: cannot find symbol

When I build with ant or javac, it will actually tell me the symbol that it can't find in the error message. maven gives me a line number and character position, but displaying the actual symbol would be more helpful. The line above is the only line given for each of the "cannot find symbol" errors. There is no line above or below that gives the symbol. I imagine there has to be some way to get maven to tell me that information, but I don't know what it is. I tried the -e option, as mvn told me to try using it, but it gave a maven traceback for the error, not the actual symbol.

Any help?

Here's the output of mvn --version

Apache Maven 3.0.4 (rNON-CANONICAL_2012-10-24_11-25_mockbuild; 2012-10-24 07:25:04-0400)
Maven home: /usr/share/maven
Java version: 1.7.0_09-icedtea, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.6.6-1.fc17.x86_64", arch: "amd64", family: "unix"

And here's an example (unhelpful) error message, exactly as output by maven (just with directories shortened):

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /path/to/source/SoundEngineFilePanel.java:[33,8] error: cannot find symbol
[ERROR]  class SoundEngineFilePanel
/path/to/source/SoundEngineFilePanel.java:[36,8] error: cannot find symbol
[INFO] 2 errors 
[INFO] -------------------------------------------------------------

The symbols it can't find are "fakeThing" and "fakeThing2", not SoundEngineFilePanel.

Answer

Peter Svensson picture Peter Svensson · Jan 4, 2013

This is a bug in the Maven compiler plugin, related to JDK7 I think. Works fine with JDK6.