46

I'm trying to import the Maven projects from IntelliJ button (the one with the arrows in circle), but I get the following message "Unable to import maven project. See logs for details", as shown in the following picture

enter image description here

If I go into the log, I see:

2015-06-01 11:16:46,932 [  89176]  ERROR -      #org.jetbrains.idea.maven - org/apache/maven/execution/MavenExecutionRequestPopulationException 
java.lang.NoClassDefFoundError: org/apache/maven/execution/MavenExecutionRequestPopulationException
    at org.jetbrains.idea.maven.server.Maven32ServerImpl.applyProfiles(Maven32ServerImpl.java:81)
    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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
    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)
Caused by: java.lang.ClassNotFoundException: org.apache.maven.execution.MavenExecutionRequestPopulationException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 16 more
2015-06-01 11:16:46,933 [  89177]  ERROR -      #org.jetbrains.idea.maven - IntelliJ IDEA 14.1.3  Build #IU-141.1010.3 
2015-06-01 11:16:46,933 [  89177]  ERROR -      #org.jetbrains.idea.maven - JDK: 1.7.0_71 
2015-06-01 11:16:46,933 [  89177]  ERROR -      #org.jetbrains.idea.maven - VM: Java HotSpot(TM) 64-Bit Server VM 
2015-06-01 11:16:46,933 [  89177]  ERROR -      #org.jetbrains.idea.maven - Vendor: Oracle Corporation 
2015-06-01 11:16:46,933 [  89177]  ERROR -      #org.jetbrains.idea.maven - OS: Linux 
2015-06-01 11:16:46,933 [  89177]  ERROR -      #org.jetbrains.idea.maven - Last Action: Maven.Reimport 

I'm using Maven 3.3.3 and JDK 1.7.0_71 on a 64bit Ubuntu machine.

Strange thing, is that I can use Maven by command line. Any idea?

JeanValjean
  • 17,172
  • 23
  • 113
  • 157

11 Answers11

54

Below one worked for me ;

Go to File > Settings > Build,Execution,Deployment> Build Tools > Maven > Importing .

Change VM options for importer to -Didea.maven3.use.compat.resolver

orkn_akgl
  • 721
  • 7
  • 14
  • 1
    This worked for me without deleting anything or going to the extreme. Try this first. – sinisterrook Oct 27 '17 at 14:11
  • 2
    @orkn_akgl, Thanks.. this worked.. just curious to know what was the issue and how does this resolution work.. can you pls elaborate a bit.. thanks : ) – Bhavuk Mathur Oct 27 '18 at 18:15
  • Welcome @BhavukMathur. I actually read some articles about this case before on some website(maybe Intellij website) and I played with that a little bit – orkn_akgl Mar 24 '19 at 18:40
  • 4
    just if someone want to recover default value: `-Xmx768m` – Lei Yang Mar 04 '20 at 10:14
  • I did this setting and it was working fine. Then it started again failing so I removed this option and it is working fine for me. – Datta Jul 08 '20 at 04:18
34

Solved. I had to remove the IntelliJ project folder (.idea) and create a new project from the existing source clicking on the parent pom. Then, everything worked properly.

I guess that some file was corrupted.


In steps. Initially you have something like:

enter image description here

After deleting the .idea folder you will have: enter image description here

So you close the project and start one from existing sources: enter image description here

You select the pom.xml file to create the new project and oveeride the IntelliJ project if one was found. enter image description here

Now you should see exactly the same as in the first picture.

JeanValjean
  • 17,172
  • 23
  • 113
  • 157
  • Can you clarify "clicking on the parent pom"? My project is made up of several maven projects. When I import as maven, I always get the error. When I import from source, it does not fail but it does not treat it as maven either. – Nathan H Dec 20 '16 at 08:02
  • This is close to the correct answer for those using intelliJ 15. Thank you :) – Tamb Jun 01 '17 at 15:58
  • The answer showing how to change vm options was the better solution. Don't do this unless the other one fails – ryan.s Nov 27 '18 at 16:08
8

I had IntelliJ IDEA 2018.2 and maven 3.6.3 couldn't work. So I updated IntelliJ IDEA to a version 2019.3 and could use maven 3.6.3.

Armine
  • 1,675
  • 2
  • 24
  • 40
7

I don't know what caused this, all i know it was very easy to fix:

  1. Download maven here and extract it in a place of your choice.
  2. Then, go to File>Settings>Build, Execution, Deployment>Build Tools>Maven.
  3. In Maven home directory, instead of Bundled maven, point it to the folder you just created.
  4. Enjoy.
Mateus Viccari
  • 7,389
  • 14
  • 65
  • 101
5

This worked for me

  1. Go to: File > Settings > Build,Execution,Deployment > Build Tools > Maven > Importing

  2. Change: JDK for importer to your installed JDK instead of IDEA's internal JRE (Use Internal JRE from ../JetBrains/IntelliJ IDEA/jre64)

Also searching in IDEA log files helped me. I found this message:

Caused by: java.io.IOException: Cannot run program "C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.2\jre64\bin\java" (in directory "C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.2\bin"): CreateProcess error=2, File not found

mzy
  • 1,754
  • 2
  • 20
  • 36
3

In my case I'd just upgraded my OS (OSX) and doing so deleted my JDK, so Intellij was quietly failing. Following @JeanValjean's advice meant that the project was no longer loadable at all (I couldn't get to JVM preferences). Looking in ~/Library/Logs/IntelliJIdeaXX/idea.log told me the problem and deleting ~/Library/Caches/IntelliJIdeaXX and ~/Library/Preferences/IntelliJIdeaXX/options/jdk.table.xml let me open the project again and fix the path to the JDK.

inanutshellus
  • 9,683
  • 9
  • 53
  • 71
3

Below is the solution that works the best for me:

Go to File > Settings > Build,Execution,Deployment> Build Tools > Maven > Importing :

Change VM options for importer to -Xmx4096m

Denys
  • 1,308
  • 12
  • 13
2

In my case it was my firewall. I use bullguard protection btw, which is pretty strict with its firewall.

Samuel
  • 21
  • 1
1

I got into this same state (unable to import maven project) several times (i was running a load test and hitting the max number of open files on the OS, so normal file saves were erroring out). It probably is a corrupt file causing this. A computer reboot acutally solved it a few times but other times I solved it by switching to command line and running "mvn clean install"

Dustin
  • 322
  • 3
  • 10
0

For me updating it to intellij 2020 worked from 2017.3.

I had tried almost all the solutions described here, but updating intellij to 2020 just worked without doing anything.

patz
  • 1,306
  • 4
  • 25
  • 42
0

Besides all solutions above, you can try close and reimport the project from IDEA. My issue solved by this simple way.

leonbear
  • 104
  • 11