Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

When trying to run mvn clean package I get the following error:

Failed to execute goal org.apache.maven.plugins:maven-compiler-
plugin:3.6.0:compile (default-compile) on project rest-webapp: 
Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:
3.6.0:compile failed: A required class was missing while executing 
org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile: 
org/codehaus/plexus/compiler/manager/NoSuchCompilerException

I found numerous suggestions to delete everything in ~/.m2/repository. Doing so does not fix the issue.

Here is my pom.xml:

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rest</groupId>
<artifactId>rest-webapp</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>rest-webapp</name>
<build>
    <finalName>rest-webapp</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <inherited>true</inherited>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.0.2</version>
            <inherited>true</inherited>
        </plugin>   
    </plugins>
</build>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.ow2.asm</groupId>
        <artifactId>asm</artifactId>
        <version>6.0_ALPHA</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-compiler-api</artifactId>
        <version>2.8.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-compiler-manager</artifactId>
        <version>2.8.1</version>
    </dependency>
</dependencies>
<properties>
    <jersey.version>2.25</jersey.version>
    <project.build.sourceEncoding>
        UTF-8
    </project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>

I am using Mac OSX 10.11.6

$JAVA_HOME is /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

$PATH is /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin:/opt/apache-maven-3.3.9/bin

Any suggestions would be greatly appreciated.

Edit: The stack trace when I run mvn clean package -X is posted here: http://pastebin.ca/3753171

Why adding plexus-compiler-api and plexus-compiler-manager as dependencies? That does not make sense...remove those dependencies... – khmarbaise Jan 3, 2017 at 20:48 Yeah I'm a little confused on what needs to be included in the pom and not. It was not working before I added them either. Thanks @khmarbaise – Stitch86 Jan 3, 2017 at 21:23

The correct way to set up command line java in OS X is to use:

export JAVA_HOME=`/usr/libexec/java_home -v1.8`

This not only sets the JAVA_HOME environment variable, but also adjusts a bunch of links in /usr/bin so that:

[steve@Steves-MacBook-Pro ~]$ which java
/usr/bin/java
[steve@Steves-MacBook-Pro ~]$ which javac
/usr/bin/javac

applies to the version that you specify in the /usr/libexec/java_home call, therefore there is no need to add $JAVA_HOME/bin to your $PATH.

I'm guessing that you have never done this, so you're getting the Java tooling from /usr/bin which is trumping your $PATH environment because it appears before /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin.

thanks for the response. I set JAVA_HOME as you said through .bash_profile, I also removed JAVA_HOME/bin from the path. I checked that both 'which' commands return the correct path. I am still getting the same error. Do you have any other suggestions? – Stitch86 Jan 4, 2017 at 0:42 java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) javac 1.8.0_45 – Stitch86 Jan 4, 2017 at 3:41 Please add the output of mvn clean package -X to your question. I built a little test project using your pom content and it works just fine with maven 3.0.5, 3.1.1, 3.2.5 and 3.3.9. – Steve C Jan 4, 2017 at 4:05
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
        </plugin>
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.