JSP imports broken in 2020.2
已回答
Our project has a few android, java and web submodules. It was working fine but after the upgrade to 2020.2 the web sub-module (JSP files and web.xml) cannot see classes ("Cannot resolve class ...") from other projects and even its own java classes.
I have noticed in the Project Structure settings, the Source Roots are missing in 2020.2. The two screenshots below are from the same project opened in 2020.1 and then in 2020.2.
It started working when I manually removed "_admin.main" module and added "Web" into the "_admin" module but it will get broken again after reimporting from Gradle.
Thanks for any help
2020.1
2020.2
2020.2 working
请先登录再写评论。
Normally, IDE creates a separate module for each source set. How do you configure these modules?
Can you show the project structure for the admin.main module to see if the Web resources directory is included in this module in 2020.2 which is created by IDE Gradle integration?
Please also attach screenshot for the Settings (Preferences) | Build, Execution, Deployment | Build Tools | Gradle from both versions? Thanks.
If possible it would be very helpful and speed up the investigation a lot if you could provide a sample project. It can be uploaded at For uploading you can use https://uploads.services.jetbrains.com - the access to it have only the IDE developers.
Thanks for your reply.
The project structure is as follows:
Settings (Preferences) | Build, Execution, Deployment | Build Tools | Gradle in both versions is exactly the same:
It would be difficult for me to create a sample project to share as this is a submodule of a big project that I cannot share.
Could you point me to what other information I can provide to help investigate? Thanks
>Settings (Preferences) | Build, Execution, Deployment | Build Tools | Gradle in both versions is exactly the same:
Interesting. For some reason this module and whole project is not imported as Gradle. Or do you use Maven?
If you are not using Maven, please import the project as Gradle project into the IDE from the (main) build.gradle file context menu.
Sorry, i took the previous screenshot when the ide was in some strange state. This is the right one. It is the same in 2020.1 and 2020.2.
The displayed project _main is the parent of the "_admin" project mentioned before. _admin contains the web files.
Is server_admin - an Android-based project? Can you provide build.gradle file for it? it would be also helpful to have the idea.log (Help | Show Log in ... action) file after IDE restart and synchronizing the Gradle project.
Normally for the Gradle-based module the IDE would mark the main source root as the IDE module - it would have the module icon:
For android-based module it could be different.
the server_admin sub-module is not an android project but there are android projects in the same parent project.
I will try again and get the log when I can
When I commented out all the android modules from settings.gradle it imported the "Web Gradle" module correctly with the Source Roots present.
Upload ID: 2020_08_18_XWxBAzVEDZc8D3BB (file: idea.log)
In log there are exceptions which are related to IDEA-222226. Such exception usually happens when incompatible Gradle, Gradle plugins and Java versions are used. In case of Android projects - Android plugin uses it's own sync. Please check that compatible JDK is used in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM. The Gradle JDK may also be taken from the Android SDK.
Which are the compatible JDKs or what is the supported combination of Gradle, Gradle plugin and Java versions and how to verify which are being used? Thanks
@premek Gradle documentation provides a compatibility matrix: https://docs.gradle.com/enterprise/compatibility/ https://docs.gradle.org/current/userguide/compatibility.html
Hi, sorry for getting back to an old question but the issue still persists. I'm on 2020.3 now
Andrey Dernov
> Such exception usually happens when incompatible Gradle, Gradle plugins and Java versions are used. In case of Android projects - Android plugin uses it's own sync. Please check that compatible JDK is used in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM. The Gradle JDK may also be taken from the Android SDK.
I'm struggling to find out which versions to check and how. I'm looking at https://docs.gradle.org/6.7.1/userguide/compatibility.html and all the versions we use seems to be fine (gradle, jvm, kotlin, android). I don't exactly understand the other link provided, the Gradle Enterprise version compatibility.
In my previous posts I showed how the project is imported in two different IDEA versions but it is with the same gradle, android etc versions, I didn't touch gradle or any other project files between trying out the two versions. So my question is version of what could be affected just by switching the idea vestion?
Please try 2020.3 IDE version from https://www.jetbrains.com/idea/download/
Do I understand you correctly that if you remove Android modules form project the dependencies are resolved correctly?
How you do add Android modules to the project? Is it an independent Gradle project or you use it as a dependency in this your Gradel module?
Also the Gradle settings shown at
> Please try 2020.3 IDE v
That's what I'm already using
> Do I understand you correctly that if you remove Android modules form project the dependencies are resolved correctly?
Yes
> How you do add Android modules to the project? Is it an independent Gradle project or you use it as a dependency in this your Gradel module?
It is one gradle project with a few subprojects, some of them are web, some are android
How do you combind all Gradle projects including Android under same IDE project? Do you use a single parent Gradle module?
Can you please also clarify classes from which dependencies are not resolved: how do you configure these dependencies in project? Thank you.
> How do you combind all Gradle projects including Android under same IDE project?
The parent module has settings.gradle with include ':xxxx' which some of those are android modules, and some web modules.
> Can you please also clarify classes from which dependencies are not resolved
Please see my first post and the screenshots. The problem is the Source roots are missing.
>The problem is the Source roots are missing.
Please check if these source roots or a directory they are located in is added into some other module in project.
Unfortunately, working with Android and non-Android project under same IDE project is not working well. It happens because Android Studio uses a bit different project structure for Gradle modules. For example it does not create separate module per each Gradle source set (e.g. in non-Android Gradle java project IDE creates two modules: main and test for each Gradle Source set but Android project will only have one module). There are related issues you can vote and follow: https://youtrack.jetbrains.com/issue/IDEA-122904 https://youtrack.jetbrains.com/issue/IDEA-205023
ok, so basically we have to use 2020.1 or separate the android modules out of our project for it to work
Could you describe your project structure a nit more and the exact issue you have: in which file do you see not resolved code? How do you configure dependencies on such unresolved code? How the Sources tabs (in File | Project Structure| Modules) look like for both such modules?
In JSP files inside this project I cannot see classes ("Cannot resolve class ...") from the same project until I do the workaround described above.
Does it help to add
under the
tag into the .idea/gradle.xml file and Reload project in Gradle tool window?
it looks like it helped
Is there a GUI for that?
There is no UI for this option. This mode has been deprecated b/c if it is used it does not reflect correct Gradle's model configuration for the corresponding IDE module.
Unfortunately the Android project can not (yet) work in "module per source set" mode but Android modules should not corrupt non-Android Gradle module's structure. I've created a request to investigate and fix this issue: https://youtrack.jetbrains.com/issue/IDEA-257879 Please vote and follow it for progress.