JustinMartinDev
JustinMartinDev

Reputation: 639

maven codehaus.mojo could not be resolved

I'm trying to build a JavaFX project with NetBeans but when i run it i have a this :

Plugin org.codehaus.mojo:exec-maven-plugin:1.2.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:exec-maven-plugin:jar:1.2.1: Could not transfer artifact org.codehaus.mojo:exec-maven-plugin:pom:1.2.1 from/to HTTP (http://repo.maven.apache.org/maven2): Access denied to: http://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/1.2.1/exec-maven-plugin-1.2.1.pom , ReasonPhrase:Forbidden. -> [Help 1]

I work behind proxy but i configured Netbeans with my proxy and i tried "Test connection" and that's work.

I had also configured the ".m2/settings.xml" directory with this proxy

<?xml  version="1.0" encoding="UTF-8"?> <settings>   <proxies>
    <proxy>
      <active />
      <protocol>http</protocol>
      <username>username</username>
      <password>password</password>
      <port>8080</port>
      <host>proxyhost</host>
      <id/>
    </proxy>   </proxies>
     <mirrors>
    <mirror>
      <id>HTTP</id>
      <name>HTTP Central</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>   </mirrors> </settings>

my 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>com.bega</groupId>
    <artifactId>Chronos</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Chronos</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mainClass>com.bega.chronos.MainApp</mainClass>
    </properties>

    <organization>
        <!-- Used as the 'Vendor' for JNLP generation -->
        <name>Your Organisation</name>
    </organization>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeScope>system</excludeScope>
                            <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>

                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/../bin/javafxpackager</executable>
                            <arguments>
                                <argument>-createjar</argument>
                                <argument>-nocss2bin</argument>
                                <argument>-appclass</argument>
                                <argument>${mainClass}</argument>
                                <argument>-srcdir</argument>
                                <argument>${project.build.directory}/classes</argument>
                                <argument>-outdir</argument>
                                <argument>${project.build.directory}</argument>
                                <argument>-outfile</argument>
                                <argument>${project.build.finalName}.jar</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>exec</goal>                            
                        </goals>
                        <configuration>
                            <executable>${java.home}/bin/java</executable>
                            <commandlineArgs>${runfx.args}</commandlineArgs>
                        </configuration>
                    </execution>
                </executions>  
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <additionalClasspathElements>
                        <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
                    </additionalClasspathElements>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>de.jensd</groupId>
            <artifactId>fontawesomefx</artifactId>
            <version>8.9</version>
        </dependency>
    </dependencies>

</project>

if anyone have a idea why that doesn't work ?

Upvotes: 14

Views: 93525

Answers (8)

Hershey
Hershey

Reputation: 39

As you can see in the stack trace the issue was that http://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/1.2.1/exec-maven-plugin-1.2.1.pom was forbidden, probably because it's HTTP and not HTTPS and your proxy blocks unsecured connections. (You can test it in the browser). Solution: Use a newer version of Netbeans where they fixed it should use by default HTTPS, see Maven dependencies are failing with a 501 error. For me, it fixed this issue.

Upvotes: 0

Robert
Robert

Reputation: 42585

I assume the repository server was temporary not working correctly. At least I was able to download the file mentioned in the error message.

Unfortunately Maven caches not-found errors. There are a lot of questions on SO about resetting the cached state and force a re-download.

IMHO the easiest way is to delete all data of the problematic artifact from the local Maven repo which is located in the subdirectory .m2/repository in your user home directory.

Open the .m2/repository and proceed to the path org/codehaus/mojo/exec-maven-plugin/. There delete the subdirectory 1.2.1 and all contained files. Maven will automatically download them the next time they are required.

Upvotes: 12

SauerTrout
SauerTrout

Reputation: 499

For me, I waiting a few minutes and tried the mvn package command again and it worked. Seems to be down once in a while, for some reason.

Upvotes: 1

Hamza AZIZ
Hamza AZIZ

Reputation: 2937

Sometimes is just about synchronization

just click the button refresh and the problem is fixed

Upvotes: 2

Arifur Rahman
Arifur Rahman

Reputation: 21

Build failure for visiting https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/1.2.1/exec-maven-plugin-1.2.1.pom from netbeans

I visited the url from browser then it showed network error . Again refresh url it loaded the response to browser I rebuild and run it loaded the project without previous problem

It seems it was network error or network proxy failure from netbeans.

Currently it is resolved

Upvotes: 0

Bender
Bender

Reputation: 92

Well i got the same error so i'm putting this here just for the sake of it somebody having the same issue. Using wagon-plugin: the dependency version got an extra digit for 2.0.0 my version was set to 2.0 and this error popped (y ofc what else d'uh)

<dependency>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>wagon-maven-plugin</artifactId>
    <version>**2.0.0**</version>
</dependency>

<dependency>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>wagon-maven-plugin</artifactId>
    <version>**1.0**</version>
</dependency>

Also for future reference they might change the reponame from codehaus to mojohaus (as of now still the old reponame). Hope this helps someone !

Upvotes: 0

Stefanny
Stefanny

Reputation: 1

Open the C:\Users\your user\\.m2\repository\org\codehaus\mojo\exec-maven-plugin, there delete the subdirectory 1.2.1, if maven doesn't download it automatically, you can use this command:

mvn dependency:purge-local-repository

Upvotes: 0

撒哈拉小哥
撒哈拉小哥

Reputation: 1

go to the local maven repostory, delete the corespondent folder. As D:\MAVENrepo\org\codehaus\mojo\exec-maven-plugin\1.2.1, use Alt+f5 to update maven project.

Upvotes: 0

Related Questions