IntelliJ not able to resolve classes of external Libraries for Maven projects

I imported a maven project and IntelliJ was able to load all the dependencies. Project is building fine. Issue is in all my files all the classes that have been used from the libraries are shown as red. As an issue I don't get the auto suggestions which is causing me lot of issues.

 

Imports shown as unused and BindingAwareProvider, LoggerFactory, Logger shown as symbols not resolved as below:

However, when I click on the api from the imports, I am able to see that jar in the external Libraries with BindingAwareBroker class as below:

External Libraries having the jars, 1 example shown below:

IntelliJ version: 15.0.2 Maven version in IDE: 3.3.3 Java: 1.7

We have a local repo from where the dependencies are getting fetched.

Can someone suggest what is wrong here? Why is the whole project messed up with red symbols. :( :(

36 comments

Please try File | Invalidate Caches | Invalidate and Restart.

10

This I have already tried. No Luck.

0

Please submit a ticket to support with idea.log (https://intellij-support.jetbrains.com/hc/articles/207241085) and a sample project to reproduce the problem.

0

Thanks Serge. The code is copyrighted, I am not sure what to provide now. Also, whether it's problem with the idea, or there is some problem on my side, don't know.

It will be nice if you just provide me with the following info:

1. If we have already existing maven project, what is the best way to import the same. Any steps documented, I have seen a lot on the internet and somehow tried all the options.

2. We have a local repo in which all the jars are placed. Can that cause some issue? Is any data other than the jars is required?

3. If I see the Jars in the external dependencies, can we say that they are added to the classpath. I am asking because all the classes and Interfaces shown as not imported are giving the following option to resolve the errors: 

However trying anyone of them is not giving any success.

 

1

1. Open the root pom.xml or import from the root pom.xml (import allows to specify more options, open uses default options).

2. It should not be a problem, the jars are enough.

3. External dependencies shows everything, it could be that the dependency is added to some other module and the module that has the problem doesn't have this specific dependency for some reason.

Please try to delete .idea directory and .iml files, then reimport the project from Maven.

2

Just a add on question for point 3:

Can I consider adding the required libraries for the particular module as dependencies? As a workaround.

I tried this for 1 module, but again, hard luck.

0

Checked with delete .idea directory and .iml files, then reimport the project from Maven. Hard Luck

2

Dependencies in a Maven project should be configured inside pom.xml instead of manually adding them in the module settings. All the changes you make there will be reverted on the next Maven project refresh/import.

0

Oh...This makes sense now. So the issue is that my project pom is having the dependencies, but when I go to the Open module dependencies -> Dependencies, it does not show those dependencies loaded.

1

Please, I have the same issue or last 72 hours I'm on 2016.3.1, pom.xml has the dependency, but module "Dependencies" tab doesn't see it, also not in .iml file also. Help!!!!! Is this a bug?

1

Is it possible to reproduce the issue with new sample project?

0

Any update on this? I also have the same issue.

1

File a ticket to support, Maven issues are not the same, need the logs and other details to find out.

0

I have similar problem, however adding the jar to Classpath seems to help.

Project Structure > Platform Settings > SDKs > Classpath 

Click the + and add the jar

 

Let me know if that was helpful

 

 

-1

It's not the correct way of managing the dependencies when using Maven, only a hacky workaround. Please contact support for help: https://intellij-support.jetbrains.com/hc/requests/new.

0

I had such an Issue with multi module projects, finally I solved the problem during the time I imported the new project.

and

That worked for me... but you might as well have another problem :)

5

Right click on project->Maven->Reimport resolved the problem

0

Hi, I have the same problem a long time. I have tried different ways to solve it but without success, for example

  1. This workaround
  2. This one

Nothing works for me.

Here is appropriate stackoverflow topic. The interesting point is that the api.iml file contains the following XML for all required dependencies, but IDEA doesn't see them.

<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar:///[my-home]/.gradle/caches/modules-2/files-2.1/com.typesafe.play/play-ws_2.11/2.4.0-M2/5a5298914b0a94ccb789d0179ede63fc35f868ab/play-ws_2.11-2.4.0-M2.jar!/"/>
</CLASSES>
<JAVADOC/>
<SOURCES>
<root url="jar:///[my-home]/.gradle/caches/modules-2/files-2.1/com.typesafe.play/play-ws_2.11/2.4.0-M2/3f4768eb9c2a5e8eaf949166d32a4f1c80e1d9e2/play-ws_2.11-2.4.0-M2-sources.jar!/"/>
</SOURCES>
</library>
</orderEntry>

Could somebody help me please, because I have not ideas what try more.

Thanks.
0

Is this topic alive still? Or I need to create another one?

0

remove the .idea project and restart the multi-module project in IDEA work for me!

IntelliJ IDEA 2016.3

4

Hi Serge,

I was too facing this same issue on Intelli14 however by following your steps, I was able to resolve this issue:-

"Please try to delete .idea directory and .iml files, then reimport the project from Maven...."

 

Thanks,

Cheers!

2

Created an account just to say that deleting the .idea directory and re-importing worked for me. Thanks for the tips.

0

Deleting the .idea directory and re-importing worked for me also.

0

Deleting the .idea directory, Restarting the project, Ticking search for projects recursively when importing module Worked for me. 

0

Deleting the .idea directory and .iml files worked for me also.

0

@Sahil Shah similar annoying problem, my issue is that i select the modules suggested by idea when i import a project,those suggested modules are like below:

with unselecting ,everything is so harmonious,no more red annoying stupid resolving problems!
hope this will help you

1

None of the above solutions worked for me. When I tried importing the maven module, I noticed it said "project is ignored", and I could not click the check box to import the module: 

I went to Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Ignored Files, and unchecked the module that was being ignored:


After this, I was given the "Import Class" option after doing the "Add Maven Dependency..." step.

1

Please sign in to leave a comment.