Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will not Run. Stuck Importing projects #1148

Open
Carsonc8 opened this issue Apr 6, 2022 · 35 comments
Open

Will not Run. Stuck Importing projects #1148

Carsonc8 opened this issue Apr 6, 2022 · 35 comments
Assignees

Comments

@Carsonc8
Copy link

Carsonc8 commented Apr 6, 2022

Issue Type: Bug

Not quite sure. Just ran my program and now stuck trying to import projects. Left it running for over 10 minutes and still the same thing.

Extension version: 0.40.0
VS Code version: Code 1.66.0 (Universal) (e18005f0f1b33c29e81d732535d8c0e47cafb0b5, 2022-03-30T05:50:04.419Z)
OS version: Darwin arm64 21.4.0
Restricted Mode: No

System Info
Item Value
CPUs Apple M1 (8 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 6, 13, 7
Memory (System) 16.00GB (4.07GB free)
Process Argv --crash-reporter-id fd4b538e-bea2-4f4f-ab94-032c1f33831e
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30443607
pythontb:30283811
pythonvspyt551cf:30345471
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
pythonvsnew555:30457759
vscscmwlcmt:30465135
cppdebug:30466689
pynewfile477:30463512

Screen Shot 2022-04-05 at 11 42 33 PM

.
@Carsonc8 Carsonc8 changed the title Will not Run. Will not Run. Stuck Importing projects Apr 6, 2022
@testforstephen
Copy link
Contributor

Can you click "check details" link to see any progress there?

Also, did you find any logs at Output channel for "Language Support for Java"?
image

@Carsonc8
Copy link
Author

Carsonc8 commented Apr 6, 2022

When clicking on output this is what it gives me.
Screen Shot 2022-04-06 at 2 14 22 PM

When clicking check details link it directs me to my terminal and proceeds to do nothing else.
Screen Shot 2022-04-06 at 2 14 50 PM

@testforstephen
Copy link
Contributor

The output channel says the extension got closed. Could you try to see the log files to get more info?

F1 -> Java: Open All Log Files

@Carsonc8
Copy link
Author

Carsonc8 commented Apr 7, 2022

Here is one of the windows that opened up when opening all log files
Screen Shot 2022-04-07 at 5 00 40 PM

Here is the second window
Screen Shot 2022-04-07 at 5 01 55 PM

@testforstephen
Copy link
Contributor

@Carsonc8 Thanks for sharing the logs. Are you running VS Code on Mac M1 chip?

The logs show that Java extension is using an embedded 17.0.2-macosx-x86_64 JRE to start Java extension itself, that won't work for arm64 architecture. The workaround is to add the user setting java.jdt.ls.java.home so that it points to your local JDK home path.

@Carsonc8
Copy link
Author

Carsonc8 commented Apr 8, 2022

Yes, I am using a Mac M1 Chip. Also, do you mind explaining how to add the user setting java.jdt.ls.java.home. I am not too familiar with VS Code.

@testforstephen
Copy link
Contributor

Here is how to change VS Code user setting.

jdtlshome.mp4

@jakopo87
Copy link

I have the same problem and downgrading the Language Support for Java(TM) by Red Hat extension from version 1.5.0 to 1.4.0 is the only thing that worked.

Versione: 1.66.2 (system setup)
Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
Data: 2022-04-11T07:46:01.075Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
Sistema operativo: Windows_NT x64 10.0.22000

@testforstephen
Copy link
Contributor

@jakopo87 The original issue is that Mac M1 used a wrong embedded JRE to launch Java extension. Your issue is different with the issue.

Could you pls share the logs in the following places?

  • Messages at ### OUTPUT panel for "Language Support for Java"
  • F1 -> Java: Open All Log Files

@throwthrowaway
Copy link

Here is how to change VS Code user setting.

jdtlshome.mp4

I think i successfully did this part but it's not working?

I opened another folder in vscode which used to work earlier, and it still works
but my current folder open will not work and is stuck at the "debug: importing projects"

@chris-hunter206
Copy link

I have this same issue. I cannot run/debug any java files. I get the identical "Debug: Importing Projects" dialog that just spins forever. I have no terminal output and no output under 'check details'.

This was working earlier today. I was getting project errors but the code would still compile and run. I restarted VSCode to reload some updates and then it started doing this. I have tried uninstalling all the java extensions and reinstalling them to no avail. Currently only have these java extensions installed, and the problem persists:

  • Debugger for Java v0.40.1
  • Language Support for Java(TM) by Red Hat v1.5.0

VScode info:

Version: 1.66.2
Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
Date: 2022-04-11T07:49:20.994Z (1 wk ago)
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Darwin x64 21.3.0

Also of note I don't have the "Run | Debug" buttons that typically appear above the main class if the code is good. (I have checked the files manually with javac and they compile and run normally that way.)

@jakopo87
Copy link

@jakopo87 The original issue is that Mac M1 used a wrong embedded JRE to launch Java extension. Your issue is different with the issue.

Could you pls share the logs in the following places?

* Messages at ### OUTPUT panel for "**Language Support for Java**"

* **F1 -> Java: Open All Log Files**

client.log.2022-04-20.log
Language Support for Java (Syntax Server).log
Language Support for Java.log
java.log

@chris-hunter206
Copy link

Oddly, in my case this seems to only affect files in the root of my java working directory. If I create a subfolder, add the java files there, and open that subfolder in VSCode, then the run/debug function works as expected.

I am not using projects, and am opening just the folder in all cases. It does not seem to matter if there is a .vscode/launch.json file or not.

@testforstephen
Copy link
Contributor

testforstephen commented Apr 24, 2022

@jakopo87 The root cause for your issue is that your VS Code user setting java.format.settings.url is pointing to file:C:/astir/eclipse-java-google-style.xml, which is not a valid url format. You should set it to file:///C:/astir/eclipse-java-google-style.xml and restart VS Code.

I will create an issue at https://github.com/redhat-developer/vscode-java/issues to report the errors more explicitly.

@jakopo87
Copy link

jakopo87 commented Apr 24, 2022

@testforstephen Changing the url fixed the issue for me, now it works on the latest version of the extension.

@testforstephen
Copy link
Contributor

I opened another folder in vscode which used to work earlier, and it still works
but my current folder open will not work and is stuck at the "debug: importing projects"

@throwthrowaway Would you mind sharing your folder structure to us? Also it would help us if you could share the logs at these places, thanks.

  • F1 -> Java: Open All Log Files

  • Messages at OUTPUT panel for "Language Support for Java"

    image

Oddly, in my case this seems to only affect files in the root of my java working directory. If I create a subfolder, add the java files there, and open that subfolder in VSCode, then the run/debug function works as expected.
I am not using projects, and am opening just the folder in all cases. It does not seem to matter if there is a .vscode/launch.json file or not.

@chris-hunter206 Would you mind sharing a minimum sample folders to help us reproduce the issue? thanks.

@testforstephen testforstephen self-assigned this Apr 29, 2022
@chris-hunter206
Copy link

I verified the problem still exists with that one folder. Here is the layout of the folder that has these issues, when it is the vscode root:


[email protected]:~/git/school/cs141_javaI [master L|✚ 1]
[19:21:05] $ l
total 1776
drwxr-xr-x  16 chunter  staff     512 May 13 19:18 .
drwxr-xr-x   8 chunter  staff     256 Apr  6 19:49 ..
-rw-r--r--@  1 chunter  staff   10244 May  9 14:03 .DS_Store
drwxr-xr-x  13 chunter  staff     416 May 10 18:06 .git
-rw-r--r--   1 chunter  staff      34 May 10 15:34 .gitignore
-rw-r--r--@  1 chunter  staff  315136 Apr  5 16:15 2022 Spring Syllabus CS& 141 - 17693.pdf
drwxr-xr-x   9 chunter  staff     288 Apr 20 20:40 Assignment1
drwxr-xr-x   5 chunter  staff     160 Apr 22 22:31 Assignment2
drwxr-xr-x   8 chunter  staff     256 May 10 15:32 Assignment3
drwxr-xr-x  24 chunter  staff     768 May 10 15:56 Assignment4
drwxr-xr-x   2 chunter  staff      64 May 13 19:18 Assignment5
-rw-r--r--@  1 chunter  staff  272796 May  3 16:12 CSD 141 Midterm Prep.pdf
-rw-r--r--@  1 chunter  staff  292885 Nov 10  2021 CSD110_9620_Fall21_Syllabus.pdf
-rw-r--r--   1 chunter  staff    1035 Apr 19 17:43 HelloWorld.java
-rw-r--r--   1 chunter  staff     228 Apr 19 22:49 Template.java
drwxr-xr-x   6 chunter  staff     192 May 10 18:06 in-class

I can open vscode using any of these subdirectories as the root fine, and everything works. it's only when I open this folder does the run function break. Also CPU usage again spiked when I had the broken root folder open in vscode. Previously this bogged the system down after a time into a completely unusable state requiring a reboot, so I didn't leave it open for long.

I tried to reproduce the issue using a minimal folder setup like this:

[email protected]:~/test [master L|…2]
[19:14:59] $ l
total 24
drwxr-xr-x   7 chunter  staff   224 May 13 19:13 .
drwxr-xr-x+ 80 chunter  staff  2560 May 13 19:05 ..
drwxr-xr-x  12 chunter  staff   384 May 13 19:07 .git
-rw-r--r--   1 chunter  staff    34 May 13 19:11 .gitignore
-rw-r--r--   1 chunter  staff  1035 May 13 19:06 HelloWorld.java
-rw-r--r--   1 chunter  staff   228 May 13 19:06 Template.java

Everything worked fine. I then copied over the Assignment1 folder and while it didn't fail in the same exact way, it did start giving me project errors about files in Assignment1/. (And this was while trying to run, for example, Template.java which is totally unrelated and has no connection to that folder). Errors are in the attached screenshot.

Of note, this were the same errors I saw initially on the day I started experiencing the problem with my root folder, that eventually deteriorated into not being able to run any java files from that folder.

The Assignment1 folder doesn't have anything special in it except the java files for that assignment, and a .vscode/launch.json file. I have not intentionally created any projects, but I suspect the editor may have added one initially when I created Assignment1, and is storing some data about that project somewhere that could possibly be corrupted. I don't offhand know where that project info might be stored, as it doesn't appear to be in the working directory anywhere.

Screen Shot 2022-05-13 at 7 17 14 PM

I have some logs I captured initially if you would like them.

@testforstephen
Copy link
Contributor

@chris-hunter206 When you simply open a standalone folder with Java files, and don't use any project system to manage source file structure, VS Code Java will try to understand your source directories. But sometimes it may fail to guess your source directories correctly. In your last screenshot, it's a typical case where Java tools fails to recognize your source directories, and it takes the folder "Assignment1" as a package name by mistake. I know you just want to take "Assignment1" as a normal folder instead Java package.

So a suggested solution is to explicitly tell Java extension how your source directories are organized. You can add a setting "java.project.sourcePaths" in your workspace ".vscode/settings.json" to explicitly configure source roots.

    // Use relative paths to mark Java source roots in your current workspace.
    "java.project.sourcePaths": [
        ".",
        "Assignment1",
        "Assignment2",
        "Assignment3",
        "Assignment4",
        "Assignment5"
    ]

@GamesDoneWr0ng
Copy link

I got the same issue with it being stuck importing projects forever, and none of the other solutions seemed to work. Here are my log files:
Logs.zip

@testforstephen
Copy link
Contributor

testforstephen commented Jun 4, 2022

@GamesDoneWr0ng Thank you for providing logs. The log shows your workspace state file is corrupted and failed to restore it, that's a duplicated issue with microsoft/vscode-java-pack#954 (comment).

Caused by: org.eclipse.core.internal.dtree.ObjectNotFoundException: Tree element '/Animation Master 1.18.2/src/main/resources/fabric.mod.json' not found.
	at org.eclipse.core.internal.dtree.AbstractDataTree.handleNotFound(AbstractDataTree.java:260)
	at org.eclipse.core.internal.dtree.DeltaDataTree.getData(DeltaDataTree.java:599)
	at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:54)
	at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63)
	at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63)
	at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63)
	at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:51)
	at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:51)
	at org.eclipse.core.internal.dtree.DeltaDataTree.asBackwardDelta(DeltaDataTree.java:91)
	at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:835)
	at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:834)
	at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:811)
	at org.eclipse.core.internal.watson.ElementTree.immutable(ElementTree.java:522)
	at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:733)
	at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1557)
	at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2482)
	at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2233)
	at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:475)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:810)
	... 33 more

You could click "F1 -> Java: Clean Java Language Server Workspace" to reset the cache.

@testforstephen testforstephen pinned this issue Jun 4, 2022
@GamesDoneWr0ng
Copy link

@testforstephen Thanks that seemed to work.

@chris-hunter206
Copy link

@chris-hunter206 When you simply open a standalone folder with Java files, and don't use any project system to manage source file structure, VS Code Java will try to understand your source directories. But sometimes it may fail to guess your source directories correctly. In your last screenshot, it's a typical case where Java tools fails to recognize your source directories, and it takes the folder "Assignment1" as a package name by mistake. I know you just want to take "Assignment1" as a normal folder instead Java package.

So a suggested solution is to explicitly tell Java extension how your source directories are organized. You can add a setting "java.project.sourcePaths" in your workspace ".vscode/settings.json" to explicitly configure source roots.

    // Use relative paths to mark Java source roots in your current workspace.
    "java.project.sourcePaths": [
        ".",
        "Assignment1",
        "Assignment2",
        "Assignment3",
        "Assignment4",
        "Assignment5"
    ]

I am not using workspaces, only opening a folder and working on the files within. I did not have any .vscode/settings.json file, but I went ahead and created one as you have suggested. That did not work. There is no change in the behavior when I open the root folder (Cannot run 'main' methods in any java file because 'importing projects' hangs forever, and CPU spikes sharply). I tried restarting VSCode but there was no change in behavior.

@chris-hunter206
Copy link

I saw your note about the workspace state file being an issue for another person, so I started looking through my logs and located the workspace data folder (~/Library/Application Support/Code/User/workspaceStorage), then dug through the various workspace.json files there. What I found was that there were a number of them that referenced bad locations. A few of these seem to point to an old location (~//Library/Application%20Support/Code/Workspaces/) which no longer exists, and a few more pointed to workspace files that have since been deleted from the filesystem. In any case, I moved these, and any workspace that referenced the root folder I am having trouble with out of that directory. (but not any that pointed to subfolders of the root).

After that, I loaded the root folder again and it seems to have fixed the issue. Initially I was getting a number of the same "Declared package does not match expected package" errors, but after selecting "Fix" and "Clear workspace cache", I am now able to successfully run java programs from that root folder. When I open various subfolders, I get prompted to add the folder to the java source path, and several files still seem to generate package errors, though the program will still execute if you select "Proceed"

Of note, when I removed the workspace data folder that pointed to the problematic root folder, it got recreated with the same numeric hash, but no workspace.json file has been created.

Another thing: The CPU spike might be a red herring for this issue. It seems to happen every time I open a new folder in vscode, and specifically is traced to a process consuming up to 100% CPU after a couple of minutes:
/Applications/Visual Studio Code.app/Contents/MacOS/Electron --ms-enable-electron-run-as-node --inspect-port=0 /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork --type=extensionHost --skipWorkspaceStorageLock

@testforstephen
Copy link
Contributor

@chris-hunter206 thank you for providing the details.

"Fix" and "Clear workspace cache" are doing the same thing as the step "F1 -> Java: Clean Java Language Server Workspace", which will remove the old cache at ~/Library/Application Support/Code/User/workspaceStorage.

Regarding the CPU spike issue, the processes you listed are from VS Code core. You may take a look at how to profiling VS Code process https://github.com/microsoft/vscode/wiki/Performance-Issues#profiling-the-renderer-process.

@MatthewMahabeer
Copy link

Yes, I am using a Mac M1 Chip. Also, do you mind explaining how to add the user setting java.jdt.ls.java.home. I am not too familiar with VS Code.

Hey Carson, did you get this fixed? & do you remember how you fixed it?

@Carsonc8
Copy link
Author

Yes, I am using a Mac M1 Chip. Also, do you mind explaining how to add the user setting java.jdt.ls.java.home. I am not too familiar with VS Code.

Hey Carson, did you get this fixed? & do you remember how you fixed it?

Hi there, unfortunately, I did not fix it but, if you look at the beginning of this thread you can see the conversation between testforstephen and I. He gave me a solution to the problem that was occurring (not sure if you are encountering the same problem.) I was still unable to fix the problem though and with finals coming up, I had to focus on other things. I would recommend going over the steps testforstephen gave me and if that still does not work you should try creating a thread with your problem and hopefully someone will be able to assist you.

@MatthewMahabeer
Copy link

Yes, I am using a Mac M1 Chip. Also, do you mind explaining how to add the user setting java.jdt.ls.java.home. I am not too familiar with VS Code.

Hey Carson, did you get this fixed? & do you remember how you fixed it?

Hi there, unfortunately, I did not fix it but, if you look at the beginning of this thread you can see the conversation between testforstephen and I. He gave me a solution to the problem that was occurring (not sure if you are encountering the same problem.) I was still unable to fix the problem though and with finals coming up, I had to focus on other things. I would recommend going over the steps testforstephen gave me and if that still does not work you should try creating a thread with your problem and hopefully someone will be able to assist you.

Thanks for replying. I wasn't able to fix it. I just discarded Lombok from my application and rewired everything and it worked for me. Thank you

@zrubing
Copy link

zrubing commented Oct 29, 2022

m1 chip too
log.log
client.log.2022-10-30.log

settins.json

  "java.configuration.runtimes": [
    {
      "name": "JavaSE-11",
      "path": "/Users/admin/.sdkman/candidates/java/11.0.17-zulu",
    },
    {
      "name": "JavaSE-1.8",
      "path": "/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home",
      "default": true
    },
    {
      "name": "JavaSE-16",
      "path": "/Users/admin/.sdkman/candidates/java/16.0.1.j9-adpt"
    }
  ],

  "java.jdt.ls.java.home": "/Users/admin/.sdkman/candidates/java/18.0.1-zulu",

@rahulbagai
Copy link

Hi everyone,

I just wanted to share my experience with the issue being discussed here. I was also facing the same problem while using Visual Studio on Github codespaces. Whenever I tried running a simple java program in the workspace, the "Run: Importing projects" would never stop and kept on loading endlessly.

I looked at multiple logs, but couldn't really figure out what was causing the problem. However, while going through this thread, I came across the suggestion to downgrade the version of Language Support for Java(TM) by Red Hat to v1.14.0 from v1.15.0 (which was released 4 days back). After reloading the workspace and rerunning the java code, everything worked flawlessly. All the java projects in my workspace were identified, and I was able to run/debug my java programs through visual code.

It took me 3-4 days to figure out this issue, and I was wondering if there is an easy way to prevent it from happening in the first place. If anyone has any inputs or suggestions, they are more than welcome.

Thanks for your time!

@testforstephen
Copy link
Contributor

Hi everyone,

I just wanted to share my experience with the issue being discussed here. I was also facing the same problem while using Visual Studio on Github codespaces. Whenever I tried running a simple java program in the workspace, the "Run: Importing projects" would never stop and kept on loading endlessly.

I looked at multiple logs, but couldn't really figure out what was causing the problem. However, while going through this thread, I came across the suggestion to downgrade the version of Language Support for Java(TM) by Red Hat to v1.14.0 from v1.15.0 (which was released 4 days back). After reloading the workspace and rerunning the java code, everything worked flawlessly. All the java projects in my workspace were identified, and I was able to run/debug my java programs through visual code.

It took me 3-4 days to figure out this issue, and I was wondering if there is an easy way to prevent it from happening in the first place. If anyone has any inputs or suggestions, they are more than welcome.

Thanks for your time!

@rahulbagai, could you share a sample project to help us to reproduce the issue?

@xp7O
Copy link

xp7O commented Feb 27, 2023

Hi guys,

I'm in the same situation...importing a spring boot project, stuck in the building process. I switched for old, release and pre-release versions of Language Support for Java(TM) by Red Hat, clean the workspace, defined the jdk in java.jdt.ls.java.home and nothing.

logs.zip

@rahulbagai
Copy link

you share a sample project to help us to reproduce the issue

@testforstephen I started with an empty repository, and create one simple Java Hello World program, and then try to run it. I even tried created a sample maven archetype, and that would also have the same issue. Please make sure you have the latest version of Java Extension Pack, and Language Support for Java(TM) by Red Hat to v1.15.0. Let me know if you are still not able to reproduce the issue.

@ongcl03
Copy link

ongcl03 commented Mar 6, 2023

Same problem here, but I just run my file in terminal and it works

@CONDEVIRSMARK
Copy link

file:///c%3A/Users/antim/Searches/Imágenes/captura de pantalla.pnghttps://open.spotify.com/track/3jXptpf8Z3aU9O1Bj6YCl0?go=1&sp_cid=fdeb0b24-8855-4637-bd13-3d659deef1e5&utm_source=embed_player_p&utm_medium=desktop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

13 participants