'Maven Fatal error compiling: directory not found: maven-compiler-plugin

I am trying to run the official Java EE 7 Tutorial code examples and get the error. I have read about it here and most of the results say that you have to check that your Maven plugin target is the same than your system JDK environment variable. My JDK_HOME is:

jdk home image

Here is my parent 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.glassfish.javaeetutorial</groupId>
    <artifactId>javaeetutorial</artifactId>
    <version>7.0.5</version>
    <packaging>pom</packaging>
    <name>javaeetutorial</name>
    
    <scm>
        <connection>scm:svn:https://svn.java.net/svn/javaeetutorial~svn/tags/javaeetutorial-7.0.0</connection>
        <developerConnection>scm:svn:https://svn.java.net/svn/javaeetutorial~svn/tags/javaeetutorial-7.0.0</developerConnection>
    </scm>
    <issueManagement>
        <system>IssueTracker</system>
        <url>http://java.net/jira/browse/JAVAEETUTORIAL</url>
    </issueManagement>
  
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <javaee.api.version>7.0</javaee.api.version>
        <maven.compiler.plugin.version>3.2</maven.compiler.plugin.version>
        <maven.source.plugin.version>2.2.1</maven.source.plugin.version>
        <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
        <maven.war.plugin.version>2.3</maven.war.plugin.version>
        <maven.acr.plugin.version>1.0</maven.acr.plugin.version>
        <maven.ear.plugin.version>2.8</maven.ear.plugin.version>
        <maven.ejb.plugin.version>2.3</maven.ejb.plugin.version>
        <maven.jar.plugin.version>2.4</maven.jar.plugin.version>
        <maven.rar.plugin.version>2.3</maven.rar.plugin.version>
        <maven.license.plugin.version>1.10.b1</maven.license.plugin.version>
        <maven.release.plugin.version>2.4.1</maven.release.plugin.version>
        <maven.exec.plugin.version>1.2.1</maven.exec.plugin.version>
        <junit.version>4.11</junit.version>
        <eclipselink.version>2.5.0</eclipselink.version>
        <glassfish.embedded.version>4.0</glassfish.embedded.version>
        <cargo.plugin.version>1.4.4</cargo.plugin.version>
        <glassfish.domain.name>domain1</glassfish.domain.name>
        <glassfish.home>${glassfish.home.prefix}/glassfish4</glassfish.home>
        <integration.container.id>glassfish4x</integration.container.id>
    </properties>
    
    <profiles>
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <glassfish.home.prefix>c:/</glassfish.home.prefix>
                <glassfish.executables.suffix>.bat</glassfish.executables.suffix>
            </properties>
        </profile>
        <profile>
            <id>unix</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <glassfish.home.prefix>${user.home}</glassfish.home.prefix>
                <glassfish.executables.suffix />
            </properties>
        </profile>
        <profile>
            <id>sdk</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <glassfish.home>${basedir}/../../../</glassfish.home>
            </properties>
        </profile>
        <profile>
            <id>development</id>
            <activation>
                <file>
                    <exists>${basedir}/../bundle</exists>
                </file>
            </activation>
            <properties>
                <glassfish.home>${glassfish.home.prefix}/glassfish4</glassfish.home>
            </properties>
        </profile>
        <profile>
            <id>standalone</id>
            <properties>
                <glassfish.home>${basedir}/target/cargo/installs/glassfish</glassfish.home>
                <cargo.maven.containerUrl>http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/latest-glassfish.zip</cargo.maven.containerUrl>
            </properties>
        </profile>
    </profiles>
    
    <modules>
        <module>archetypes</module>
        <module>batch</module>
        <module>case-studies</module>
        <module>cdi</module>
        <module>concurrency</module>
        <module>connectors</module>
        <module>ejb</module>
        <module>jaxrs</module>
        <module>jaxws</module>
        <module>jms</module>
        <module>persistence</module>
        <module>security</module>
        <module>web</module>
    </modules>
    
    <repositories>
        <repository>
            <id>snapshot-repository.java.net</id>
            <name>Java.net Snapshot Repository for Maven</name>
            <url>https://maven.java.net/content/repositories/staging/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>releases-repository.java.net</id>
            <name>Java.net releases Repository for Maven</name>
            <url>https://maven.java.net/content/repositories/releases/</url>
            <layout>default</layout>
        </repository>
    </repositories>
    
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven.source.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>${maven.clean.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven.war.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <version>${cargo.plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>deploy</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>redeploy</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <container>
                        <containerId>${integration.container.id}</containerId>
                        <type>installed</type>
                        <home>${glassfish.home}</home>
                    </container>
                    <configuration>
                        <type>existing</type>
                        <home>${glassfish.home}/glassfish/domains</home>
                        <properties>
                            <cargo.glassfish.domain.name>${glassfish.domain.name}</cargo.glassfish.domain.name>
                            <!--cargo.remote.username></cargo.remote.username-->
                            <cargo.remote.password />
                        </properties>
                    </configuration>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.mycila.maven-license-plugin</groupId>
                <artifactId>maven-license-plugin</artifactId>
                <version>${maven.license.plugin.version}</version>
                <configuration>
                    <header>common/license.txt</header>
                    <excludes>
                        <exclude>common/**</exclude>
                        <exclude>**/META-INF/**</exclude>
                        <exclude>**/WEB-INF/**</exclude>
                        <exclude>**/nbactions.xml</exclude>
                        <exclude>**/nb-configuration.xml</exclude>
                        <exclude>**/glassfish-resources.xml</exclude>
                        <exclude>**/simple-flow-flow.xml</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven.release.plugin.version}</version>
                <configuration>
                    <!--
                     During release:perform, enable the "sdk" profile
                    -->
                    <releaseProfiles>sdk</releaseProfiles>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>${javaee.api.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

</project>

My child 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <artifactId>servlet</artifactId>
        <groupId>org.glassfish.javaeetutorial</groupId>
        <version>7.0.5</version>
    </parent>
    
    <groupId>org.glassfish.javaeetutorial</groupId>
    <artifactId>hello2</artifactId>
    <version>7.0.5</version>
    <packaging>war</packaging>

    <name>hello2</name>   
</project>

after I run MVN install I get the error:

enter image description here

Any help will be highly appreciated!



Solution 1:[1]

You are compiling a project inside your Program Files. Those folders are often write protected.

Re-install Glassfish into a Document folder where read/write is not an issue.

Maven does not tend to have the world's most helpful error messages - here the issue is not that directory cannot be found, it seems more like a directory could not be created!

Solution 2:[2]

Great feeback. Did a chmod on the repo directory and that Practically solved the problem for me. Thanks

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Roman Zenka
Solution 2 Digital Oga Naija