Compiler cannot find classes which are available in Editor. Project can be built with maven

Answered

Trying to build my project I got 168 errors like "Error:(26, 8) java: The import org.hibernate cannot be resolved" or "Error:(43, 26) java: Log cannot be resolved to a type". The editor shows the imports as OK and I can navigate to the imported classes. Maven can build the whole project just fine.

 

I've

  • reimported all maven projects
  • deleted my whole maven repository
  • rebuilt the project several times
  • invalidated classes and cache
  • tried javac and eclipse compiler as java compilers

I have not started a new project because it's huge and setting it up again takes ages. I don' think that's the proper solution though anyway.

0
7 comments

Try to delete .idea directory and import pom.xml again.

1
Avatar
Permanently deleted user

I don't have an ".idea" directory. I have a project directory with all my IML files and stuff in it. I guess deleting that would be the same? That's what I want to prevent because setting up the project again takes forever (multiple root modules with 586 pom.xml files).

0

Do you use the legacy project format based on IPR file instead of the .idea directory based format? .idea should be in the project root.

Why do you configure it manually instead of importing the root pom.xml file?

1
Avatar
Permanently deleted user

No, I use the directory based format. When I import a pom.xml I enable "Keep project files in...".

I  have a couple of different root pom.xmls which I all have to import. Setting up the project again (by which I mean importing the six pom.xml) takes a long time because then IDEA has to compile and index everything again.  I'm working on huge project with a large code base. Also other project related settings get lost which is a massive waste of time. The restructuring and renaming of modules to usable names alone is a PITA every time.

We've had problems like this for months on several developer machines. Usually setting up a new project does indeed fix the problem but I don't consider that a valid solution...

0

The problem like this would be nearly impossible to fix without a reproducible test case.

If you have any project that you could share with us and that will show this problem, please upload it: https://intellij-support.jetbrains.com/hc/articles/206869619.

If you can't upload the entire project, share all the pom.xml files preserving the directories structure, also share .idea directory files and all the .iml files. Attach idea.log and build.log with debug info after reproducing the problem (delete all the logs first, enable debug mode for build, reproduce the problem, zip and attach all the logs). You can provide all the requested information via a ticket at https://youtrack.jetbrains.com/issues/IDEA since you can't attach the files in this forum. YouTrack also allows private attaches visible only to JetBrains staff, see https://intellij-support.jetbrains.com/hc/articles/207241135.

1
Avatar
Permanently deleted user

I will try to build a project that can reproduce this. Thanks for the efforts.

 

In the meantime I created a completely new project and imported some POMs. I still get the errors in the compiler. As the affected files are distributed all over the project I effectively cannot use IDEA anymore without having to build and run everything manually with maven.

0
Avatar
Permanently deleted user

I've reverted some changes in our pom.xmls and now I can build.

A colleague can reproduce it on his machine with 2017.1.2 so it's not a new problem.

0

Please sign in to leave a comment.