Introduction
This is an article where the main focus is just to solve and handle an appearance of an error messaage. Basically, the error appear on the process of building, compiling and running a Java application. All the processes are in a Java IDE which in this context, it is using NetBeans 8.2. The following is actually the output which is exist from the Output Tab :
cd C:\repository\development\apps; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_181" cmd /c "\"\"C:\\netbeans-8.2\\java\\maven\\bin\\mvn.bat\" -Dnetbeans.deploy=true -Dmaven.ext.class.path=C:\\netbeans-8.2\\java\\maven-nblib\\netbeans-eventspy.jar -Dfile.encoding=UTF-8 package\"" Scanning for projects... ------------------------------------------------------------------------ Building apps 0.1-SNAPSHOT ------------------------------------------------------------------------ Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom ------------------------------------------------------------------------ BUILD FAILURE ------------------------------------------------------------------------ Total time: 19.801s Finished at: Tue Feb 15 14:19:08 ICT 2022 Final Memory: 6M/123M ------------------------------------------------------------------------ Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1] To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging. For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
The above are the error message which is appearing after doing several sequences activity. The following are those activities :
-
First of all, opening the Java Project from NetBeans 8.2. It is done by accessing File > Open Project… menu.
-
Next, building the project by selecting the project and do a right click in it.
-
Select the Run menu and click it to execute the process for building, compiling and running the project. Do not forget to set the maven tool in the NetBeans in order to use the internal integrated maven with the NetBeans IDE.
Solution
After googling it, there are several alternative solutions in several websites. The problem is when the process for building the Java application, it need several libraries available in the maven repository. But connecting to the maven repository need an HTTPS connection. So, after trying to dig in to several articles, there is one which is running properly. That article for an alternative solution exist in this link. It is a stackoverflow page which is giving a specific instruction for solving it. In this case, the following are the sequences for implementing the solution :
-
Check the maven location. Specifically, the maven tool which is internally integrated with NetBeans. For an example, it exist in ‘C:/netbeans-8.2/java/maven’.
-
In order to solve the problem, there is a configuration for specifying the HTTPS connection which must be exist in the maven configuration file. The maven configuration file in this context, it exist in ‘C:/netbeans-8.2/java/maven/conf’. The file name is ‘settings’ and the following is the configuration for enabling the HTTPS connection :
<mirror> <id>central-secure</id> <url>https://repo.maven.apache.org/maven2</url> <mirrorOf>central</mirrorOf> </mirror>
The full configuration for the mirroring section exist as follow after the modification :
<!-- mirrors | This is a list of mirrors to be used in downloading artifacts from remote repositories. | | It works like this: a POM may declare a repository to use in resolving certain artifacts. | However, this repository may have problems with heavy traffic at times, so people have mirrored | it to several places. | | That repository definition will have a unique id, so we can create a mirror reference for that | repository, to be used as an alternate download site. The mirror site will be the preferred | server for that repository. |--> <mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>central-secure</id> <url>https://repo.maven.apache.org/maven2</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
-
After adding that specific configuration, just run the process once more. If there are no errors appear, the process for building, compiling and running the Java program using maven in NetBeans will not be a problem anymore.
One thought on “How to Solve Error Message Return code is: 501 , ReasonPhrase:HTTPS Required when building Java Program using maven in NetBeans”