Vscode-java: Does not resolve to a ICompilationUnit

Created on 8 Oct 2018  路  18Comments  路  Source: redhat-developer/vscode-java

RedHat Language for Java is just not working
No linter, no code suggestions, no "popups" on hovering, anything

I'm able to get the following error:
[Error - 21:08:10] 08-Oct-2018 21:08:10 file:///home/diego/GitHub/MAKEROID/Makeroid/appinventor/components/src/com/google/appinventor/components/runtime/util/crypt/MakeroidAES256.java does not resolve to a ICompilationUnit

It happens when the extension tries to read any file
I already tried deleting the extension and installing it again

Environment
  • Operating System: Debian 9
  • JDK version: 10 (tried as well on 8)
  • Visual Studio Code version: 1.28
  • Java extension version: Latest
Steps To Reproduce
  1. Just open any file

image

Current Result

It should be working

Expected Result

It's not working

Additional Informations

It was working time ago, but one day it stopped working, I don't know why

Most helpful comment

Make sure to have a org.eclipse.jdt.core.javanature in your .project file.

I had the same issue with Apache flink -mvn eclipse:eclipse did the trick. This also generates the .classpath.

All 18 comments

Looks like an Android application. FYI vscode-java doesn't support Android project development.

I have the exact same problem. Everything was working 2-3 days ago and right now there's just no code suggestions, no linting etc. I tried updating VSCode, reinstalling the extension multiple times. Nothing fixed it.

Here's a screenshot :
ss 2018-10-11 at 04 38 15

This is not an Android project, I only have .java files

I'm on Windows 7 with JDK 8.

@fbricon it is but it doesn't work with normal Java files
@Fudgyking could replicate the issue, so I think it's not releated with the Android project

Actually I just noticed that it still works when I open another folder I worked in before.
The only difference between the two I could find were some gradle files that were commited by a collaborator. I'm currently trying to get rid of them and see if it fixes anything.

Try deleting vscode-java's working directory and restart VS Code (Next version will provide a command to do it directly from VS Code)

After removing the gradle files on version control, deleting my local workspace and recloning, it started working again on my side. I couldn't test your option since I already fixed it.

I am still getting this issue even after performing the clean java workspace command in VS Code.

After cleaning the language server workspace, the problem is solved.
But why? Are we depending on something outside of our source code to compile project? like classpath/source path settings?

I also seem to have this problem on one of the projects. Cleaning workspace does not fix it.

I can reproduce it every single time. It is a Maven project.

Just initialize this project in an empty folder:

mvn archetype:generate \
    -DarchetypeGroupId=org.apache.kafka \
    -DarchetypeArtifactId=streams-quickstart-java \
    -DarchetypeVersion=2.3.0 \
    -DgroupId=streams.examples \
    -DartifactId=streams.examples \
    -Dversion=0.1 \
    -Dpackage=myapps

Open in VSC and it complains about ICompilationUnit
VSC: 1.37.1
vscode-java: 0.47.0

I also seem to have this problem on one of the projects. Cleaning workspace does not fix it.

I can reproduce it every single time. It is a Maven project.

Just initialize this project in an empty folder:

mvn archetype:generate \
    -DarchetypeGroupId=org.apache.kafka \
    -DarchetypeArtifactId=streams-quickstart-java \
    -DarchetypeVersion=2.3.0 \
    -DgroupId=streams.examples \
    -DartifactId=streams.examples \
    -Dversion=0.1 \
    -Dpackage=myapps

Open in VSC and it complains about ICompilationUnit
VSC: 1.37.1
vscode-java: 0.47.0

I have this problem too, same maven project (from kafka streams tutorial).

Make sure to have a org.eclipse.jdt.core.javanature in your .project file.

I had the same issue with Apache flink -mvn eclipse:eclipse did the trick. This also generates the .classpath.

I started seeing the same issue recently as well.
Cleaning java language server workspace does not fix for me. However, running mvn eclipse:eclipse resolves the problem and that does seem to work for me.

But I don't believe that should actually be required and is kind of a pain to figure it out...

I have this problem too, same maven project (from kafka streams tutorial).

You can try the following:

diff --git a/pom.xml b/pom.xml
index e25730f..f62bde4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -114,7 +114,9 @@
                                         </goals>
                                     </pluginExecutionFilter>
                                     <action>
-                                        <ignore/>
+                                        <configurator>
+                                            <id>org.eclipse.m2e.jdt.javaConfigurator</id>
+                                        </configurator>
                                     </action>
                                 </pluginExecution>
                             </pluginExecutions>

But I don't believe that should actually be required and is kind of a pain to figure it out...

@yxw Could you paste the content of your pom.xml?

I got the same problem with an gradle project.
In my .project file it lists org.eclipse.buildship.core.gradleprojectnature as nature.
I also tried to remove all project files and restart vscode but it didn't helped.
Then I executed clean java langauge server workspace but didn't helped neither.

In the output panel I got the following error:

[Error - 10:16:27] 28.11.2019 10:16:27 Cannot decrypt model file Illegal key size java.security.InvalidKeyException: Illegal key size at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039) at javax.crypto.Cipher.implInit(Cipher.java:805) at javax.crypto.Cipher.chooseProvider(Cipher.java:864) at javax.crypto.Cipher.init(Cipher.java:1396) at javax.crypto.Cipher.init(Cipher.java:1327) at com.microsoft.jdtls.intellicode.core.pythia.PythiaModelLoader.decrypt(PythiaModelLoader.java:76) at com.microsoft.jdtls.intellicode.core.pythia.PythiaModelLoader.access$0(PythiaModelLoader.java:70) at com.microsoft.jdtls.intellicode.core.pythia.PythiaModelLoader$1.run(PythiaModelLoader.java:57)
I don't if this is important.

I think that's rather caused by the missing jce for strong authentication.

I think this bug can be closed as this is rather related to project setups - maybe it only needs a doc update or hint?

I fixed my problem by adding GRADLE_HOME to my environment variables pointing to my gradle installation

I got this problem with an Apache Felix OSGI Project.

Edit: I fixed it with an mvn eclipse:eclipse and cleaning java language server workspace, after initialising the project with eclipse (generated .project and .properties files) It would be nice if the java language server could read the project structure from maven alone, so an eclipse configuration isn't needed.

I just discovered when working with a workspace containing multiple maven projects, that for the single maven projects the plugin does not create a .settings folder containing the "org.eclipse.*" files.

If I open the maven project as a folder in a separate window, then the "org.eclipse.*" files will be created and the issue does not appear + auto-complete works.

Update

Cleaning the workspace as described here solved the issues.

cheers
flash :zap:

Was this page helpful?
0 / 5 - 0 ratings