73

Maybe you can help me I got a strange apache maven's problem, when opening my project at Intellij Idea 13. When projects was open I have no libraries at External Libraries section. And at all pom.xml files from diff's modules I see error "Cannot reconnect". enter image description here

I tried to Invalidate Cache/Restart Idea, try to use Maven Reimport but problem still take a place. But if I do mvn clean install, and deploy my projects everything works fine. I use Maven 3.2.3. and Java 1.8.

Maven settings: enter image description here

Aded idea.log files:

2015-06-03 11:54:24,585 [ 441715]   INFO -      #org.jetbrains.idea.maven - Cannot reconnect. 
java.lang.RuntimeException: Cannot reconnect.
    at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:98)
    at org.jetbrains.idea.maven.server.MavenEmbedderWrapper.resolveProject(MavenEmbedderWrapper.java:97)
    at org.jetbrains.idea.maven.project.MavenProjectReader.resolveProject(MavenProjectReader.java:462)
    at org.jetbrains.idea.maven.project.MavenProject.resolve(MavenProject.java:624)
    at org.jetbrains.idea.maven.project.MavenProjectsTree.resolve(MavenProjectsTree.java:1215)
    at org.jetbrains.idea.maven.project.MavenProjectsProcessorResolvingTask.perform(MavenProjectsProcessorResolvingTask.java:42)
    at org.jetbrains.idea.maven.project.MavenProjectsProcessor.doProcessPendingTasks(MavenProjectsProcessor.java:131)
    at org.jetbrains.idea.maven.project.MavenProjectsProcessor.access$100(MavenProjectsProcessor.java:28)
    at org.jetbrains.idea.maven.project.MavenProjectsProcessor$2.run(MavenProjectsProcessor.java:107)
    at org.jetbrains.idea.maven.utils.MavenUtil$6.run(MavenUtil.java:440)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
Caused by: java.rmi.ServerError: Error occurred in server thread; nested exception is: 
    java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:351)
    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$254(TCPTransport.java:683)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/99407688.run(Unknown Source)
    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:745)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
    at com.sun.proxy.$Proxy121.resolveProject(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.execution.rmi.RemoteUtil$2$1$1.compute(RemoteUtil.java:106)
    at com.intellij.execution.rmi.RemoteUtil.executeWithClassLoader(RemoteUtil.java:167)
    at com.intellij.execution.rmi.RemoteUtil$2$1.invoke(RemoteUtil.java:102)
    at com.sun.proxy.$Proxy121.resolveProject(Unknown Source)
    at org.jetbrains.idea.maven.server.MavenEmbedderWrapper$4.execute(MavenEmbedderWrapper.java:100)
    at org.jetbrains.idea.maven.server.MavenEmbedderWrapper$4.execute(MavenEmbedderWrapper.java:97)
    at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:89)
    ... 16 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
    at org.apache.maven.wagon.providers.file.FileWagon.resolveDestinationPath(FileWagon.java:206)
    at org.apache.maven.wagon.providers.file.FileWagon.resourceExists(FileWagon.java:265)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:577)
    at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
    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)
2015-06-03 11:54:24,586 [ 441716]   WARN - ution.rmi.RemoteProcessSupport - Exception in thread "pool-6-thread-1" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils 
2015-06-03 11:54:24,586 [ 441716]   WARN - ution.rmi.RemoteProcessSupport - at org.apache.maven.wagon.providers.file.FileWagon.resolveDestinationPath(FileWagon.java:206) 
MeetJoeBlack
  • 2,804
  • 9
  • 40
  • 66
  • My guess is that there is a problem with your IntelliJ Maven plugin, but that running Maven from the command line is working without issue. – Tim Biegeleisen Jun 03 '15 at 08:51
  • @TimBiegeleisen - you could right click and open it in new tab. It is big enough. @MeetJoeBlack - please check `idea.log` and see what error details are present there. – ring bearer Jun 03 '15 at 08:51
  • Have you tried using the bundled Maven instead of the command line one? http://puu.sh/iaG9U/bd94fce2ba.png – Crembo Jun 03 '15 at 09:01
  • 2
    My problem was solved by updating /etc/hosts file. [Refer this](https://stackoverflow.com/a/12702961/1686291) – Not a bug Dec 04 '18 at 17:02
  • @Notabug My man, saved my day. This issue was irritating and I was simply switching the JDK for importer multiple times in a session. In my hosts file 127.0.0.1 was mapped to Kubernetes as well by docker desktop apart from localhost. Commented out and it works like a charm now. Thank you. – cyanotrix Feb 09 '23 at 11:32

10 Answers10

193

I was facing the same error and fixed it like that:

  1. Open settings by pressing Ctrl+Alt+S and navigate to Build, Execution, Deployment | Build Tools | Maven | Importing

  2. Check JDK for Importer and change the exact version of JDK (example : 1.8.0.250) installed on your machine from the drop-down.

enter image description here

After doing the same it prompts for verification and after that, the maven will be automatically updated and the project will run.

In my case, I did the same thing as the JDK which is used in the machine is different when the project is imported from a repository. These things happen when we uninstall the IDE and JDK and install the IDE and different version of JDK, the IDE automatically fetch the project which is available in the machine as before but it can not change the imported JDK.

ax.
  • 58,560
  • 8
  • 81
  • 72
Subhajit
  • 1,931
  • 2
  • 5
  • 3
  • 8
    This should be marked as the solution instead. – Marks Gniteckis Apr 15 '21 at 08:07
  • This works for me for a while then it fails again and I need to switch again (switching to any option works). It seems the problem lies somewhere else but you can work around it switching JDK from time to time. – domaru Jun 21 '21 at 15:16
  • 3
    Amazingly, this actually worked for me even though it was already set correctly. I just selected it again from the dropdown, pressed Apply and OK, and I was able to download just fine. Strange! – devinbost Oct 06 '21 at 19:24
  • This worked for me just through opening the settings page and clicking “OK” to close the dialog – I had nothing to change. Next time I’ll try opening the dialog without navigating to that screen (because this happens to me for time to time as well…) – Didier L Aug 22 '22 at 13:33
  • In the end what really works for me is clicking reload project until it succeeds… It might be that IntelliJ doesn’t like the fact that Docker Desktop messes with the hosts file, looking at _Not a bug_’s comment on the question – Didier L Sep 23 '22 at 16:15
  • Changing the project SDK had the same effect for me (without ever touching Maven settings) – hughjdavey Jan 12 '23 at 12:47
  • If you are getting this repeatedly then please check the hosts file as commented above by @Notabug. In my case I was getting this even after changing the JDK for importer. It was an issue with my hosts file. – cyanotrix Feb 09 '23 at 11:33
  • 1
    For anyone, with multiple java versions like me, you need to select the version set as JAVA_HOME for this to work. – Skillzore Mar 16 '23 at 09:21
23

I fixed this by changing my local Maven 3.3.9 to Idea Bundle Maven3.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
luffy
  • 231
  • 2
  • 2
23

Clicking on Reload All Maven Projects helped me in this scenario.

enter image description here

matua
  • 597
  • 4
  • 12
9

File -> Invalid Cache

might also be helpful in a scenario where IntelliJ seems to tangle up itself.

Simeon
  • 748
  • 1
  • 9
  • 26
  • Nothing else worked for me, except this.... Hitting Invalidate Cache.... It instantly reloaded everything from top to bottom as like new.... I was trying hard for hours on this, but this solution helped me get around the issue.... You're a saviour man, Thank you – Aravindh Sivalingam Sep 14 '21 at 10:38
  • Any weird intellij issue -> invalidate caches. Downside is you need to restart the app and with it all the services you're running. – gdrt Dec 14 '22 at 18:29
3

In case you are running InteliJ in WSL with X-Server (e.g. VcXsrv), a solution may be to

  1. close InteliJ
  2. restart the server
  3. open Intelij

and it will be working.

LoukasPap
  • 1,244
  • 1
  • 8
  • 17
1

I fixed this problem by removing .lastUpdated files coming from transfer error in ~/.m2

find ~/.m2  -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;
Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
1

In my case, restarting IntelliJ solved the problem.

0

I was getting this error and I fixed this error in IntelliJ by following steps:

1] close all running application(if any)
2] reimport/reload pom.xml (right-click on pom.xml -> select maven option->reimport/reload project)
3] then run your application(i.e. main file) by following this I did not needed to delete the .m2 folder manually

0

In my case, I have maven runner and importer set to use Project JDK, but I managed to solve this problem by changing JDK from OpenJDK to Liberica JDK (same Java version) and it magically started working.

So for anyone with similar problem, try to change JDK to different implementation.

everis
  • 316
  • 4
  • 11
0

Cause IDE launches Maven import in a separate java process and communicates with it using java RMI calls which work via local loopback interface (localhost). To access the loopback interface the localhost hostname is used. When IDE is unable to establish connection to a localhost this error occurs. There could be several causes why localhost is not accessible:

DNS misconfiguration The 127.0.0.1 is the standard address for IPv4 loopback traffic and the localhost name must resolve to 127.0.0.1 IPv4 address. If it is not - the error will occur.

Antivirus or firewall blocks connections to localhost

Resolution Make sure the localhost hostname resolves to 127.0.0.1 IPv4 loopback address. It is better to leave only localhost name for the 127.0.0.1 address. For this the hosts file must have only following lines for mapping localhost to IPv4 and IPv6 local addresses:

Quick Solution restart the Intelij IDE.