About Maven Proxy Authentication Errors in the Corporate Environment

Asked 2 months ago, Updated 2 months ago, 6 views

This is my first time to ask a question.Thank you for your cooperation.

There is a problem with the subject, and I would like your advice.

We are currently deploying maven on Windows 7 as an in-house development environment*.
Note: In-house Development Environment
- OS: Windows 7 SP1 - maven version: Apache Maven 3.3.9
- Java version: 1.8.0_60
- Others: Internet connectivity via corporate proxy (with user account authentication)

When you deploy maven in Windows 7 and attempt to create a sample project with the following commands, an error message appears:

○ Input command (command prompt)

 mvnarchtype: create-DgroupId=com.example-DartifactId=sample

○ Error log (excerpt from command prompt)

...
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.maven.apache.org/maven2 via [Internal Proxy Server Name]: [Port for Proxy] with username = [Internal Proxy Account Name], password = ***
… (omitted)
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Error transferring file: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required" from https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml with proxyInfo ProxyInfo{host='[社内プロキシserver name]', userName='null', port=[port for proxy], type='https', nonProxyHosts='null'}
org.eclipse.aether.transfer.MetadataTransferException: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Error transferring file: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required" from https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml with proxyInfo ProxyInfo { host='[Company Proxy Server Name]', userName='null', port=[Port for Proxy], type='https', nonProxyHosts='null'}

(↑ A large number of 407 errors have occurred as described above.)

Proxy settings are set to %UserProfile%\.m2\settings.xml as follows:

○ settings.xml Settings

<settings>
  <proxies>
    <proxy>
      <id>proxy-http</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>[Company Proxy Server Name]</host>
      <port> Proxy Ports</port>
      <username>[Company Proxy Account Name]</username>
      <password>[Internal Proxy Password]</password>
    </proxy>
    <proxy>
      <id>proxy-https</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>[Company Proxy Server Name]</host>
      <port> Proxy Ports</port>
      <username>[Company Proxy Account Name]</username>
      <password>[Internal Proxy Password]</password>
    </proxy>
  </proxies>
</settings>

As far as the DEBUG line in the command prompt display log shows, the proxy server name and proxy account can be retrieved from settings.xml, but the error line shows that ProxyInfo {host='[Company Proxy Server Name]', userName='null', port=[ProxyPort for Proxy], type='http',nonProxyHosts='nullName}.

We are investigating various past cases, but there were no past cases that have been resolved, so we are asking questions on this website.
It is difficult to verify proxy server configuration because it is in the company environment.

If anyone knows the solution, I would appreciate it if you could advise me.

java windows maven

2022-09-30 14:01

2 Answers

What are the results of editing conf/setting.xml in the maven installation directory?

If that works, I think the global setting works first.
https://maven.apache.org/settings.html

Check the value of the environment variable M2_HOME


2022-09-30 14:01

When I looked at the log, I found that there was an Eclise ether log that should not have been output just by using normal maven.
http://www.eclipse.org/aether/

You are running maven using this ether.

Also, it is important to check the environment variable (PATH) of your PC, but I am running it with the command

 mvnarchtype: create-DgroupId=com.example-DartifactId=sample

There is a suspicion that you have a proxy configuration written in the pom.xml in the sample project, or that you have specified a profile, and that you are rewriting the proxy configuration while loading profile.xml.


2022-09-30 14:01

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.