11

Summary

I've seen a few questions [1] [2] [3] that resemble this somewhat, but none of the answers have produced any sort of success.

So, here are the issues that I am seeing:

1) The pom is indicating that it is not able to connect to the local .m2 repository.

2) The Maven setting in Intellij is showing an error that the connection to the local .m2 repository is refused.

enter image description here

Connection to local repository has been refused

What I have tried so far:

Pretty much everything in the linked issues. Including:

1) Delete the entire .m2/repository folder manually, and then update your Maven project again.

2) Invalidate your Idea cache and restart Idea.

3) increasing Maven's allocated memory

4) Setting localhost to only 127.0.0.1

5) Adding -Djava.net.preferIPv4Stack=true flag

6) Starting Intellij with Java 1.7 instead of 1.8

7) Uninstalling and re-installing Maven, Java, and Intellij

Other information:

$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

$ mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T12:39:06-07:00)
Maven home: /usr/local/apache-maven-3.5.0
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"

Any help is greatly appreciated.

Idea.log

2017-08-29 13:16:51,471 [12172337]   WARN -      #org.jetbrains.idea.maven - Failed to update Maven indices for: [local] /Users/donato/.m2/repository 
org.jetbrains.idea.maven.server.MavenServerIndexerException: Connection refused to host: localhost; nested exception is: 
    java.net.ConnectException: Connection refused (Connection refused)
    at org.jetbrains.idea.maven.server.Maven3ServerIndexerImpl.updateIndex(Maven3ServerIndexerImpl.java:221)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
    at com.sun.proxy.$Proxy137.updateIndex(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.execution.rmi.RemoteUtil.invokeRemote(RemoteUtil.java:175)
    at com.intellij.execution.rmi.RemoteUtil.access$300(RemoteUtil.java:36)
    at com.intellij.execution.rmi.RemoteUtil$2$1$1.compute(RemoteUtil.java:156)
    at com.intellij.execution.rmi.RemoteUtil.executeWithClassLoader(RemoteUtil.java:232)
    at com.intellij.execution.rmi.RemoteUtil$2$1.invoke(RemoteUtil.java:153)
    at com.sun.proxy.$Proxy137.updateIndex(Unknown Source)
    at org.jetbrains.idea.maven.server.MavenIndexerWrapper$3.execute(MavenIndexerWrapper.java:120)
    at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:118)
    at org.jetbrains.idea.maven.server.MavenIndexerWrapper.updateIndex(MavenIndexerWrapper.java:115)
    at org.jetbrains.idea.maven.indices.MavenIndex.updateContext(MavenIndex.java:371)
    at org.jetbrains.idea.maven.indices.MavenIndex.updateOrRepair(MavenIndex.java:329)
    at org.jetbrains.idea.maven.indices.MavenIndices.updateOrRepair(MavenIndices.java:128)
    at org.jetbrains.idea.maven.indices.MavenIndicesManager.doUpdateIndices(MavenIndicesManager.java:276)
    at org.jetbrains.idea.maven.indices.MavenIndicesManager.access$200(MavenIndicesManager.java:52)
    at org.jetbrains.idea.maven.indices.MavenIndicesManager$3.run(MavenIndicesManager.java:243)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:718)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:170)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:548)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:493)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:157)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:165)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:343)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: 
    java.net.ConnectException: Connection refused (Connection refused)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
    at com.sun.proxy.$Proxy29.setIndeterminate(Unknown Source)
    at org.jetbrains.idea.maven.server.Maven3ServerIndexerImpl.updateIndex(Maven3ServerIndexerImpl.java:152)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.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.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:211)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
    ... 24 more
2017-08-29 13:17:07,836 [12188702]   WARN - ution.rmi.RemoteProcessSupport - java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - java.net.ConnectException: Connection refused (Connection refused) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at com.sun.proxy.$Proxy1.ping(Unknown Source) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at com.intellij.execution.rmi.RemoteServer.start(RemoteServer.java:83) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at org.jetbrains.idea.maven.server.RemoteMavenServer.main(RemoteMavenServer.java:22) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - Caused by: java.net.ConnectException: Connection refused (Connection refused) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at java.net.PlainSocketImpl.socketConnect(Native Method) 
2017-08-29 13:17:07,841 [12188707]   WARN - ution.rmi.RemoteProcessSupport - at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at java.net.Socket.connect(Socket.java:589) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at java.net.Socket.connect(Socket.java:538) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at java.net.Socket.<init>(Socket.java:434) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at java.net.Socket.<init>(Socket.java:211) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613) 
2017-08-29 13:17:07,842 [12188708]   WARN - ution.rmi.RemoteProcessSupport - ... 8 more 
2017-08-29 13:17:21,180 [12202046]   INFO - .script.IdeScriptEngineManager - javax.script.ScriptEngineManager initialized in 34 ms 
2017-08-29 13:17:23,080 [12203946]   INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS) 
2017-08-29 13:17:23,756 [12204622]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /Applications/IntelliJ IDEA CE.app/Contents/lib/jps-launcher.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/tools.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/optimizedFileManager.jar 
2017-08-29 13:17:23,859 [12204725]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
2017-08-29 13:17:23,860 [12204726]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation 
2017-08-29 13:17:23,860 [12204726]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
2017-08-29 13:17:27,244 [12208110]   INFO - pl.ProjectRootManagerComponent - project roots have changed 
2017-08-29 13:17:27,299 [12208165]   INFO - pl.ProjectRootManagerComponent - project roots have changed 
2017-08-29 13:17:27,305 [12208171]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 0ms; general responsiveness: ok; EDT responsiveness: ok 
2017-08-29 13:17:27,324 [12208190]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update canceled 
2017-08-29 13:17:27,325 [12208191]   INFO - pl.ProjectRootManagerComponent - project roots have changed 
2017-08-29 13:17:27,333 [12208199]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 2ms; general responsiveness: ok; EDT responsiveness: ok 
2017-08-29 13:17:27,336 [12208202]   INFO - lij.compiler.impl.CompilerUtil -    COMPILATION FINISHED (BUILD PROCESS); Errors: 100; warnings: 3 took 4150 ms: 0 min 4sec 
2017-08-29 13:17:27,365 [12208231]   INFO - s.CompilerReferenceServiceImpl - backward reference index reader is opened 
2017-08-29 13:17:27,369 [12208235]   INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 36ms; general responsiveness: ok; EDT responsiveness: ok 
2017-08-29 13:17:27,635 [12208501]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /Applications/IntelliJ IDEA CE.app/Contents/lib/jps-launcher.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/tools.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/optimizedFileManager.jar 
2017-08-29 13:17:27,704 [12208570]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
2017-08-29 13:17:27,704 [12208570]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation 
2017-08-29 13:17:27,704 [12208570]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 

Update

Which settings.xml are you using?

/Users/donato/.m2/settings.xml

Does this happen with any Maven project you open in IntelliJ or just this one?

This occurs with all maven projects

Also, apart from Intellij showing indexing failure, does your build work if invoked from the Maven panel?

Build fails, stating that a lot of symbols cannot be found.

Donato Perconti
  • 814
  • 2
  • 11
  • 28
  • 4
    Without the errors in the [idea.log](https://intellij-support.jetbrains.com/hc/articles/207241085) it's not possible to tell what's the problem in your specific case. See also http://stackoverflow.com/a/42427510/104891. – CrazyCoder Aug 29 '17 at 01:15
  • 1
    Does this happen with any Maven project you open in IntelliJ or just this one? Also, apart from Intellij showing indexing failure, does your build work if invoked from the Maven panel? – Abhijit Sarkar Aug 29 '17 at 02:30
  • 1
    Which `settings.xml` are you using? Check here: File > Settings > Build,.. > Build Tools > Maven > User settings file – Sam Aug 29 '17 at 09:31
  • I've included the idea.log along with answers to the other questions. – Donato Perconti Aug 29 '17 at 20:21
  • 1
    About `settings.xml` I meant does this file, that the IDEA uses, contain the correct path to the repository? If the file doesn't exist, then the default location is `~/.m2` – Sam Aug 30 '17 at 07:09
  • Yes, the settings.xml contains the correct path to the repo. – Donato Perconti Sep 01 '17 at 05:03
  • 1
    Suggest two things here. First, scan your environment for related settings such as maven_opts and proxy or, more specifically, no_proxy--in Terminal, "env | grep -i maven_opts" and "env | grep -i proxy". Second, look at "/Users/donato/.m2/settings.xml" closely with respect to presence of a nonProxyHosts node within any proxy node you may have configured--do you include localhost as a nonProxyHost? – unigeek Sep 20 '17 at 18:17
  • 1
    See this. If it can work for you.https://stackoverflow.com/questions/15685686/java-rmi-connectexception-connection-refused-to-host-127-0-1-1 – Muhammad Danish Khan Sep 21 '17 at 06:14
  • 2
    Do you have a firewall in place which prevents IntelliJ to accept some incoming network connections? see this post [why-does-intellij-want-to-accept-incoming-network-connections](https://stackoverflow.com/questions/43444949/why-does-intellij-want-to-accept-incoming-network-connections). It's a pure guess. – SubOptimal Sep 21 '17 at 06:19

2 Answers2

8

Finally figured out the issue. There was an invalid character in my /etc/hosts file which was preventing any connection to localhost. This was discovered when I entered the following command:

$ file -b /etc/hosts
UTF-8 Unicode text

I manually entered in the correct values in etc host and now everything is now working as expected.

Donato Perconti
  • 814
  • 2
  • 11
  • 28
5

I have two suggestions:

  1. If there is a proxy, add its configuration parameters in setting.xml You must specify:

    <proxy> <active></active> <protocol></protocol> <host></host> <port></port> <username></username> <password></password> </proxy>

  2. Copy/Paste 127.0.0.1 localhost in your hosts file

karmens89
  • 156
  • 5