redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 441 forks source link

Does not resolve to a ICompilationUnit #667

Open barreeeiroo opened 6 years ago

barreeeiroo commented 6 years ago

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
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

fbricon commented 6 years ago

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

Fudgyking commented 6 years ago

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.

barreeeiroo commented 6 years ago

@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

Fudgyking commented 6 years ago

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.

fbricon commented 6 years ago

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

Fudgyking commented 6 years ago

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.

Phonesis commented 6 years ago

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

maxiwu commented 5 years ago

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?

gregd72002 commented 5 years ago

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

ghost commented 5 years ago

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).

mojadev commented 5 years ago

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.

yxw commented 5 years ago

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...

snjeza commented 5 years ago

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?

Bno93 commented 4 years ago

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.

mojadev commented 4 years ago

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?

Bno93 commented 4 years ago

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

devantler commented 4 years ago

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.

flash-me commented 4 years ago

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:

bertin0 commented 2 years ago

This also happens to me on a java 8 gradle project. Neither cleaning the workspace nor running the eclipse gradle plugin fixed the issue for me. Also, running with java.import.gradle.home set to openjdk 19 instead of 8 solves the issue (partially, as the project is not actually buildable with jdk 19, but at least completion and error highlighting works properly)

i also noticed that errors are only highlighted on save, so I guess that they are only found by the filesystem watcher.

kouritron commented 2 years ago

its happening to me as well. I am trying to run the flink hello world here: https://flink.apache.org/q/quickstart.sh

vscode + recommended java extension pack, can not open this project and do anything more than notepad w/ it.

After several hrs, finally found the suggestion above. Open a terminal and run

mvn eclipse:eclipse

and vscode suddenly lights up, w/ warnings and errors and everything seemingly as it should be. Nice intro to java/flink for a mostly python/c dev :|

snjeza commented 2 years ago

@kouritron You can try to remove

<pluginExecution>
    <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <versionRange>[3.1,)</versionRange>
        <goals>
            <goal>testCompile</goal>
            <goal>compile</goal>
        </goals>
    </pluginExecutionFilter>
    <action>
        <ignore/>
    </action>
</pluginExecution>

from pom.xml

DoisKoh commented 1 year ago

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

This worked for me.

dreamworld commented 1 year ago

its happening to me as well. I am trying to run the flink hello world here: https://flink.apache.org/q/quickstart.sh

vscode + recommended java extension pack, can not open this project and do anything more than notepad w/ it.

  • [x] Tried installing openjdk-17. play w/ versions. nothing.
  • [x] Clear language workspace directory. nope.
  • [x] Try 10 diff versions of redhat.java. still nope.

After several hrs, finally found the suggestion above. Open a terminal and run

mvn eclipse:eclipse

and vscode suddenly lights up, w/ warnings and errors and everything seemingly as it should be. Nice intro to java/flink for a mostly python/c dev :|

this works at first but later I realize it is not a perfect solution for the long run. It is the manually generated eclipse project files that get recognized by vscode, not the Maven pom.xml file

icdevin commented 1 year ago

@kouritron You can try to remove

<pluginExecution>
  <pluginExecutionFilter>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <versionRange>[3.1,)</versionRange>
      <goals>
          <goal>testCompile</goal>
          <goal>compile</goal>
      </goals>
  </pluginExecutionFilter>
  <action>
      <ignore/>
  </action>
</pluginExecution>

from pom.xml

This worked for me after many hours of debugging. Thank you.

raykrueger commented 6 months ago

Hello from 2024, this is still a problem if you use the mvn archetype for apache Flink. It will inject this plugin config into your pom.xml. For whatever reason the pluginExecutionFilter mentioned above turns VSCode into Notepad. I lost almost 3 hours on this.

coolCucumber-cat commented 2 months ago

fixed it with the command "Java: Clean Java Language Server Workspace"

19tylermalone94 commented 1 month ago

its happening to me as well. I am trying to run the flink hello world here: https://flink.apache.org/q/quickstart.sh

vscode + recommended java extension pack, can not open this project and do anything more than notepad w/ it.

* [x]  Tried installing openjdk-17. play w/ versions. nothing.

* [x]  Clear language workspace directory. nope.

* [x]  Try 10 diff versions of redhat.java. still nope.

After several hrs, finally found the suggestion above. Open a terminal and run

mvn eclipse:eclipse

and vscode suddenly lights up, w/ warnings and errors and everything seemingly as it should be. Nice intro to java/flink for a mostly python/c dev :|

Here in 2024, I am working on a repo that has front end (React) and backend (Java with Maven), and VSCode Java Projects has issues recognizing. I did what this person said to generate the eclipse .classpath file, reloaded the window, and everything works. Thanks @kouritron