Maven "failed to parse error message" (Java 7 + Maven 2)

I have a maven based GWT project that includes Guava. I am having problems trying Maven (and failing) to compile sources found in guava-gwt*.jar :

 could not parse error message: symbol: static setCountImpl location: class /home/mark/.m2/repository/com/google/guava/guava-gwt/11.0.1/guava-gwt-11.0.1.jar(com/google/common/collect/AbstractMultiset.java):100: error: cannot find symbol return setCountImpl(this, element, count); ^ 

I cannot understand why Maven believes that it should compile sources in guava-gwt . This is what my project looks like:

 β”œβ”€β”€ pom.xml └── src  β”œβ”€β”€ main  β”‚  └── java  └── test  └── java  └── SomeTestFile.java 

SomeTestFile.java

 import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import org.junit.Test; public class SomeTestFile { @Test public void testMethod() { Multimap<Integer, String> someMap = ArrayListMultimap.create(); someMap.put(5, "five"); System.out.println(someMap); } } 

pom.xml

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>guava-problem</groupId> <artifactId>guava-problem</artifactId> <version>1.0</version> <dependencies> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>11.0.1</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava-gwt</artifactId> <version>11.0.1</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project> 

I have already tried the following:

  • Removing guava dependencies (leaving only guava-gwt )
  • Scoping guava-gwt to provided

I'm not sure what else to try. guava-gwt includes sources because GWT compiles it into equivalent Javascript. But I do not want Maven to try to compile these sources.

Edit

Just a note ... the test files themselves do not need guava-gwt over guava , because they are compiled and executed as Java code (they do not go through the GWT compilation stage). I don't need guava-gwt specifically for these tests, but it should be available for my actual GWT client code.

Maven full exit

 mark@mark-peters:~/devel/guava-problem$ mvn -V clean test-compile Apache Maven 2.2.1 (rdebian-1) Java version: 1.7.0 Java home: /usr/lib/jvm/jdk1.7.0/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "2.6.32-38-generic" arch: "amd64" Family: "unix" [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - guava-problem:guava-problem:jar:1.0 [INFO] task-segment: [clean, test-compile] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean {execution: default-clean}] [INFO] Deleting file set: /home/mark/devel/guava-problem/target (included: [**], excluded: []) [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, ie build is platform dependent! [INFO] skip non existing resourceDirectory /home/mark/devel/guava-problem/src/main/resources [INFO] [compiler:compile {execution: default-compile}] [INFO] Nothing to compile - all classes are up to date [INFO] [resources:testResources {execution: default-testResources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, ie build is platform dependent! [INFO] skip non existing resourceDirectory /home/mark/devel/guava-problem/src/test/resources [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Compiling 1 source file to /home/mark/devel/guava-problem/target/test-classes [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Compilation failure /home/mark/.m2/repository/com/google/guava/guava-gwt/11.0.1/guava-gwt-11.0.1.jar(com/google/common/collect/AbstractMultiset.java):[19,0] error: cannot find symbol could not parse error message: symbol: static setCountImpl location: class /home/mark/.m2/repository/com/google/guava/guava-gwt/11.0.1/guava-gwt-11.0.1.jar(com/google/common/collect/AbstractMultiset.java):100: error: cannot find symbol return setCountImpl(this, element, count); ^ could not parse error message: symbol: method setCountImpl(AbstractMultiset<E>,E,int) location: class AbstractMultiset<E> where E is a type-variable: E extends Object declared in class AbstractMultiset /home/mark/.m2/repository/com/google/guava/guava-gwt/11.0.1/guava-gwt-11.0.1.jar(com/google/common/collect/AbstractMultiset.java):105: error: cannot find symbol return setCountImpl(this, element, oldCount, newCount); ^ [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Tue Feb 21 12:49:42 EST 2012 [INFO] Final Memory: 18M/212M [INFO] ------------------------------------------------------------------------ 

Change (again)

Having established that the source of the problem has nothing to do with Guava, but rather in the Maven version (see my answer ), I updated the title and question to be more useful for future users.

+10
java maven guava gwt
Feb 15 2018-12-15T00:
source share
5 answers

TL; DR

Maven 2 and JDK 7 are incompatible as Maven is trying to parse the javac output that has changed in JDK 7.

Full explanation

Raghuram noticed that this worked for him in Maven 3+, and I took the path of studying this not as a configuration problem, but as a real Maven problem. I started doing more tests and found that this problem:

  • Occurs with Java 7 and Maven 2.2.1.
  • Doesn't happen with Java 7 and Maven 3+
  • Doesn't happen with Java 6 and Maven 2.2.1

So, at that moment it became clear to me that the errors β€œfailed to parse the error message” were relevant, and the problem probably had less to do with guava-gwt compilation and was more related to Maven, not knowing how to handle the errors correctly.

To test this, I created a separate Maven project that has nothing to do with Guava:

 β”œβ”€β”€ pom.xml └── src └── main  └── java  └── ClassWithWarnings.java 

pom.xml

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>maven-problem</groupId> <artifactId>maven-problem</artifactId> <version>1.0</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArgument>-Xlint:all</compilerArgument> <showWarnings>true</showWarnings> <showDeprecation>true</showDeprecation> </configuration> </plugin> </plugins> </build> </project> 

ClassWithWarnings.java

 public class ClassWithWarnings implements java.io.Serializable {} 

Lo and behold, Maven tanks in this project, and also when using Java 7:

 mark@mark-peters:~/devel/maven-problem$ mvn -V compile Apache Maven 2.2.1 (rdebian-1) Java version: 1.7.0 Java home: /usr/lib/jvm/jdk1.7.0/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "2.6.32-38-generic" arch: "amd64" Family: "unix" [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - maven-problem:maven-problem:jar:1.0 [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, ie build is platform dependent! [INFO] skip non existing resourceDirectory /home/mark/devel/maven-problem/src/main/resources [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 1 source file to /home/mark/devel/maven-problem/target/classes [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Compilation failure could not parse error message: warning: [options] bootstrap class path not set in conjunction with -source 1.3 /home/mark/devel/maven-problem/src/main/java/ClassWithWarnings.java:1: warning: [serial] serializable class ClassWithWarnings has no definition of serialVersionUID public class ClassWithWarnings implements java.io.Serializable {} ^ [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: < 1 second [INFO] Finished at: Tue Feb 21 13:10:47 EST 2012 [INFO] Final Memory: 14M/150M [INFO] ------------------------------------------------------------------------ 

With Java 6, it still reports warnings, but can analyze the Javac output and not tank like this:

 Apache Maven 2.2.1 (rdebian-1) Java version: 1.6.0_20 Java home: /usr/lib/jvm/java-6-openjdk/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "2.6.32-38-generic" arch: "amd64" Family: "unix" [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - maven-problem:maven-problem:jar:1.0 [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, ie build is platform dependent! [INFO] skip non existing resourceDirectory /home/mark/devel/maven-problem/src/main/resources [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 1 source file to /home/mark/devel/maven-problem/target/classes [WARNING] /home/mark/devel/maven-problem/src/main/java/ClassWithWarnings.java:[1,7] [serial] serializable class ClassWithWarnings has no definition of serialVersionUID [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: < 1 second [INFO] Finished at: Tue Feb 21 13:18:39 EST 2012 [INFO] Final Memory: 9M/150M [INFO] ------------------------------------------------------------------------ 

The problem seems to be that the latest version of Maven 2 does not know how to parse error messages with Java 7+ javac. Maven 3 does. I still have not found documentation about this, and I'm a little surprised that Maven does not give a warning when trying to compile a version of the JDK that does not know how to properly support it.

+22
Feb 21 '12 at 18:23
source share

Converting my comment to response ...

The exact pom file along with the test class above is compiled in my windows box using maven 3.0.4.

The problem may be using the version of maven you are using. Or there may be other maven targets in the actual pom, which may cause problems.

+2
Feb 21 '12 at 4:30
source share

For a similar problem, I upgraded maven-compiler-plugin to a later version.

+2
Jul 20 '12 at 8:27
source share

It so happened that we received the same failure, but with gradle instead of maven. After switching from ArrayListMultimap to LinkedListMultimap, the error disappeared. It looks like ArrayListMultimap is at least disabled in version 11.0.2.

+2
Oct 24
source share

It doesn't seem like he is trying to compile Guava libraries, but without the full maven build log, we cannot say.

Judging by the information that you have published so far, instead you will see two incompatible versions of the class or library on the way to the classes at compile time.

I am going to try your test project and see if I can provide you more information.

EDIT:

So, I found a couple of interesting things. Firstly, I was able to get your project to work without a lot of fanfare :(

I changed my pom to:

  <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>11.0.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava-gwt</artifactId> <version>11.0.1</version> <scope>runtime</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> 

By default, the test file will not run. I reorganized it so that it is now called SomeTestFileTest , which will actually run the test.

I am running Maven v2.2.1 on OSX. Before starting, I also cleaned my ~ / .m2 / repository file. I suggest you try the same thing: nuke is your local repository folder and try building again. If this does not work, let me know which version of maven you are using.

+1
Feb 20 '12 at 18:49
source share



All Articles