1

Since I upgraded to a fresh installation of Ubuntu 16.04, I can't compile my Java project with any of my installed JDKs, for instance this one:

$ sudo update-alternatives --config java
There are 4 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority       Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java          1082      auto mode
  1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  2            /usr/lib/jvm/java-8-oracle/jre/bin/java          1082      manual mode
* 3            /usr/lib/jvm/jdk1.8.0_65/bin/java                100       manual mode
  4            /usr/lib/jvm/jdk1.8.0_92/bin/java                100       manual mode

Compiling my maven project:

$ mvn clean install -DskipTests

...
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ 

dearjohn ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 101 source files to /home/ariel/workspace/dearjohn/target/classes
An exception has occurred in the compiler (1.8.0_65). Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) after checking the database for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.IllegalStateException: endPosTable already set
    at com.sun.tools.javac.util.DiagnosticSource.setEndPosTable(DiagnosticSource.java:136)
    at com.sun.tools.javac.util.Log.setEndPosTable(Log.java:350)
    at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:667)
    at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.<init>(JavacProcessingEnvironment.java:892)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.next(JavacProcessingEnvironment.java:921)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1187)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:125)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:823)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:352)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:197)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] An unknown compilation problem occurred
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Same error happens with the other Java versions I have installed. Using Maven 3.3.9

Tried it on a remote box at work with Ubuntu 12.04 and java build 1.8.0_91-8u91-b14-0ubuntu4~12.04-b14 and no compilation errors. Tried the closest thing on my 16.04 with java 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14, getting the same error as above.

A breakdown to different phases results with mvn compile passing, but mvn package causing the error.

  • Seems related to http://stackoverflow.com/questions/36408706/java-lang-illegalstateexception-endpostable-already-set Did you check with jdk7 or lower? – Pradeeban Kathiravelu Aug 10 '16 at 22:37
  • My project uses some Java 8 features so that's not a possibility... – Ariel Stolerman Aug 10 '16 at 22:39
  • Probably the upgrade messed up with your environment variables. Check whether maven uses the java version that you prefer to. Your maven uses version 1.8.0_65. What does "java -version" from terminal return? – Pradeeban Kathiravelu Aug 10 '16 at 22:43
  • Same:$ java -version java version "1.8.0_65" Java(TM) SE Runtime Environment (build 1.8.0_65-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode) – Ariel Stolerman Aug 10 '16 at 22:45
  • "A breakdown to different phases results with mvn compile passing, but mvn package causing the error." So this is more of mvn build failure after upgrade than being unable to "compile java on Ubuntu 16.04" (as indicated by your title). Fixing the title to indicate/include maven may get more relevant audience. I will get back to this later if I get some idea or hint. – Pradeeban Kathiravelu Aug 10 '16 at 22:51
  • Try installing Java from the PPA https://launchpad.net/~webupd8team/+archive/ubuntu/java – Johnny V Aug 10 '16 at 23:10
  • Also try to upgrade maven-compiler-plugin to 3.5.1 and see whether that fixes. – Pradeeban Kathiravelu Aug 11 '16 at 19:16

1 Answers1

1

it's a bug in 3.2 & 3.3 versions of maven-compiler-plugin.

when running the 'mvn package' second time, the previously generated source directory is added to the source path before the generate-source phase and it causes this parser exception.

Switching back to the older version 3.2 for exemple, of maven-compiler-plugin fixes the issue.

Note that the incremental compilation is broken in 3.0 & 3.1 versions of maven-compiler-plugin. So, I prefer to switch the 2.5.1 version of maven-compiler-plugin.

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.5.1</version>
</dependency>
viudes
  • 11
  • 2