Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 478735 - Eclipse Mars: Download repository index updates on startup - fails
Summary: Eclipse Mars: Download repository index updates on startup - fails
Status: CLOSED WONTFIX
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 critical with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-30 11:13 EDT by Kiran Mohan CLA
Modified: 2021-04-19 13:23 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kiran Mohan CLA 2015-09-30 11:13:37 EDT
Eclipse Mars m2e plugin fails to download repository index updates on startup. I run eclipse behind company firewall but proxy setting are working for "check for updates", "eclipse marketplace", eclipse inbuilt browser,....

Proxy configurations are correctly set in $HOME/.m2/settings.xml. 
Standalone Maven properly downloads dependencies when run 

I hv already tried the following
1. Deleting the cache directory "\eclipse\p2\org.eclipse.equinox.p2.repository\cache" and then refreshing the repositories. Preferences -> Install Update -> Available Software Sites => select the entry and click the "Reload"
2. Adding "-Djava.net.preferIPv4Stack=true" to -vmargs in eclipse.ini

Please help me resolve this. Due to this issue, eclipse fails to search and add dependency from maven repositories.

Here is the error in .metadata/.log
eclipse.buildId=4.5.0.I20150603-2000
java.version=1.8.0_60
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_IN
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.m2e.logback.appender 4 0 2015-09-30 14:39:59.820
!MESSAGE Unable to update index for central|https://repo.maven.apache.org/maven2
!STACK 0
java.net.ConnectException: Connection timed out: connect
        at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at com.squareup.okhttp.internal.Platform.connectSocket(Platform.java:107)
        at com.squareup.okhttp.Connection.connect(Connection.java:156)
        at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:175)
        at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120)
        at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:330)
        at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:319)
        at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
        at com.squareup.okhttp.Call.getResponse(Call.java:271)
        at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228)
        at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199)
        at com.squareup.okhttp.Call.execute(Call.java:79)
        at io.takari.aether.okhttp.OkHttpAetherClient.execute(OkHttpAetherClient.java:154)
        at io.takari.aether.okhttp.OkHttpAetherClient.get(OkHttpAetherClient.java:100)
        at org.eclipse.m2e.core.internal.index.nexus.AetherClientResourceFetcher.retrieve(AetherClientResourceFetcher.java:79)
        at org.apache.maven.index.updater.AbstractResourceFetcher.retrieve(AbstractResourceFetcher.java:35)
        at org.apache.maven.index.updater.DefaultIndexUpdater.downloadIndexProperties(DefaultIndexUpdater.java:452)
        at org.apache.maven.index.updater.DefaultIndexUpdater.access$100(DefaultIndexUpdater.java:75)
        at org.apache.maven.index.updater.DefaultIndexUpdater$IndexAdaptor.setProperties(DefaultIndexUpdater.java:607)
        at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:788)
        at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:135)
        at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.updateRemoteIndex(NexusIndexManager.java:1127)
        at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.updateIndex(NexusIndexManager.java:1084)
        at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager$1.run(NexusIndexManager.java:656)
        at org.eclipse.m2e.core.internal.index.nexus.IndexUpdaterJob.run(IndexUpdaterJob.java:72)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Fred Bricon CLA 2015-09-30 12:20:53 EDT
Do you know what kind of proxy is being used?

FYI, NTLM proxies are currently not supported, due to OkHttp, the underlying transport library, not supporting it. See https://github.com/square/okhttp/issues/206
Comment 2 Kiran Mohan CLA 2015-10-01 06:49:29 EDT
(In reply to Fred Bricon from comment #1)

Could you guide me to identify if my company proxy is NTLM proxy or not?
Comment 3 Kiran Mohan CLA 2015-10-01 07:47:30 EDT
(In reply to Fred Bricon from comment #1)

I think OkHttp does work with my company proxy. I believe there is something wrong with eclipse/m2e in retrieving the proxy settings. Please read the rest of this message for details.

Here is a simple program with OkHttp that works with my company proxy.
-------------------------------------------------------------
	public static void main(String[] args) {
		
		String proxy = "<company proxy>";
		String port = "<port>";
		Properties systemProperties = System.getProperties();
		systemProperties.setProperty("http.proxyHost",proxy);
		systemProperties.setProperty("http.proxyPort",port);
		systemProperties.setProperty("https.proxyHost",proxy);
		systemProperties.setProperty("https.proxyPort",port);
		
		OkHttpClient client = new OkHttpClient();
		String url = "https://repo.maven.apache.org/maven2/archetype-catalog.xml.sha1";
//		String url = "https://github.com/square/okhttp/blob/master/LICENSE.txt";
//		String url = "http://maven.apache.org/pom.html";
		Request request = new Request.Builder().url(url).build();

		Response response;
		try {
			response = client.newCall(request).execute();
			String outStr = response.body().string();
			System.out.println(outStr);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
-------------------------------------------------------------

If the http.* properties are not set, it throws connection time out error. Everything works if the proxy properties are set. So OkHttp works with my company proxy server.

Now I tried to add http.* properties in eclipse.ini, but it still didn't work. 

-------------------------------------------------------------
!SESSION 2015-10-01 17:03:19.888 -----------------------------------------------
eclipse.buildId=4.5.0.I20150603-2000
java.version=1.8.0_60
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_IN
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.839
!MESSAGE System property http.proxyHost has been set to <company proxy> by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.844
!MESSAGE System property http.proxyPort has been set to <port> by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.846
!MESSAGE System property http.nonProxyHosts has been set to localhost|127.0.0.1 by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.849
!MESSAGE The HTTP proxy is enabled in the preferences but disabled in the system settings

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.850
!MESSAGE The SSL proxy is enabled in the preferences but disabled in the system settings

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.853
!MESSAGE System property https.proxyHost has been set to <company proxy> by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.854
!MESSAGE System property https.proxyPort has been set to <port> by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.856
!MESSAGE System property https.nonProxyHosts has been set to localhost|127.0.0.1 by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2015-10-01 17:03:28.857
!MESSAGE The SSL proxy is enabled in the preferences but disabled in the system settings

!ENTRY org.eclipse.m2e.logback.appender 4 0 2015-10-01 17:04:23.792
!MESSAGE Unable to update index for central|https://repo.maven.apache.org/maven2
!STACK 0
java.net.ConnectException: Connection timed out: connect
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at com.squareup.okhttp.internal.Platform.connectSocket(Platform.java:107)
        at com.squareup.okhttp.Connection.connect(Connection.java:156)
        at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:175)
        at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120)
        at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:330)
        at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:319)
        at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
        at com.squareup.okhttp.Call.getResponse(Call.java:271)
        at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228)
        at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199)
        at com.squareup.okhttp.Call.execute(Call.java:79)
        at io.takari.aether.okhttp.OkHttpAetherClient.execute(OkHttpAetherClient.java:154)
        at io.takari.aether.okhttp.OkHttpAetherClient.get(OkHttpAetherClient.java:100)
        at org.eclipse.m2e.core.internal.index.nexus.AetherClientResourceFetcher.retrieve(AetherClientResourceFetcher.java:79)
        at org.apache.maven.index.updater.AbstractResourceFetcher.retrieve(AbstractResourceFetcher.java:35)
        at org.apache.maven.index.updater.DefaultIndexUpdater.downloadIndexProperties(DefaultIndexUpdater.java:452)
        at org.apache.maven.index.updater.DefaultIndexUpdater.access$100(DefaultIndexUpdater.java:75)
        at org.apache.maven.index.updater.DefaultIndexUpdater$IndexAdaptor.setProperties(DefaultIndexUpdater.java:607)
        at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:788)
        at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:135)
        at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.updateRemoteIndex(NexusIndexManager.java:1127)
        at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.updateIndex(NexusIndexManager.java:1084)
        at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager$1.run(NexusIndexManager.java:656)
        at org.eclipse.m2e.core.internal.index.nexus.IndexUpdaterJob.run(IndexUpdaterJob.java:72)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

-------------------------------------------------------------
Comment 4 Denis Polivanov CLA 2016-05-05 11:07:54 EDT
I've found solution. It's quite simple. After some code investigation I've found following thing: https://github.com/eclipse/m2e-core/blob/releases/1.6/1.6.2.20150902-0002/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java#L1226

So m2e scans proxy list and trying to find correct by protocol. If you look at central url: https://repo.maven.apache.org/maven2. So correct protocol is "https"

Your proxy settings should looks like that (one proxy for http and second for https):

<proxies>
  <proxy>
    <active>true</active>
    <protocol>http</protocol>
    <host>myproxy.company.com</host>
    <port>8080</port>
  </proxy>
    <proxy>
      <active>true</active>
      <protocol>https</protocol>
      <host>myproxy.company.com</host>
      <port>8080</port>
    </proxy>
</proxies>

Don't think it is Bug
Comment 5 Benjamin Garn CLA 2016-08-17 04:51:31 EDT
Setting up a https proxy in settings.xml is working in general. Unfortunatly there's still a bug, because the proxy credentials are ignored. It results in following error: 

  Unable to update index for central|https://repo.maven.apache.org/maven2
  java.io.IOException: Failed to authenticate with proxy

After some research i guess the credentials are getting lost somewhere in OkHttpAetherClient. The code, that is supposed to handle the proxy authentication is never reached. Recently a new version (0.16) of aether-connector-okhttp as been released and the part handling the proxy authentication was changed. So maybe a library update would fix it...
Comment 6 Eclipse Genie CLA 2017-08-18 18:09:57 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Denis Roy CLA 2021-04-19 13:23:15 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/