问题
I'm having the follow error when I launch a Hudson job like mvn clean compile
.
[INFO] Compiling 1541 source files to /users/applis/33g/ad33gwas/.hudson/jobs/sonar facade-commande/workspace/facade-commande/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
An exception has occurred in the compiler (1.5.0_12). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError
Do you have any idea of reason of this issue?
回答1:
You've encountered a compiler bug. It is not clear which bug it might be, but there is a good chance that it would be fixed by upgrading to a later version of the JDK.
(You are apparently running java 1.5.0_u12, and that is pretty ancient. The last freely available patch release for Java 1.5 is java 1.5.0_u22. The are more recent 1.5 releases (to 1.5.0._u34) available for people with a Java for Business subscription. Alternatively, you could upgrade to Java 1.6 or 1.7.)
回答2:
I had this issue several times. You are already lucky that the compiler is even reporting an error because in my case it did not and Maven was failing later on with some ununderstandable error.
Eventually, I found out that the compiler was not handling some complex typing (something like <A extends MyObject<A1,A2>, A1 extends MyObject2<A2>, A2 extends MyObject3>
) very well. Updating the JVM may solve your issue but is also likely to stumble on again as your code evolves. It seems that these kind of errors has disappeared in JDK-7 but I can't be sure.
Anyway, one solution is to use an alternate compiler for your code (like tycho), you can do it like this in your pom.xml (either in build-->plugins or build-->pluginManagement-->plugins):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${compiler.source}</source>
<target>${compiler.target}</target>
<encoding>${source.encoding}</encoding>
<fork>false</fork>
<compilerId>jdt</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-jdt</artifactId>
<version>0.13.0</version>
</dependency>
</dependencies>
</plugin>
If you are using Eclipse and M2E 1.0 or above, you will get an error, but you can get rid of it by adding the following snippet to your pom.xml (in build-->pluginManagement-->plugins):
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<versionRange>[2.0,)</versionRange>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<parameters>
<compilerId>jdt</compilerId>
</parameters>
</pluginExecutionFilter>
<action>
<configurator>
<id>org.eclipse.m2e.jdt.javaConfigurator</id>
</configurator>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
Quite ugly and the problem has been reported to m2e developers but they don't consider this as a priority so you have to live with it
来源:https://stackoverflow.com/questions/9768702/compilation-error-failure-executing-javac-but-could-not-parse-the-error