vscode-java-kotlin icon indicating copy to clipboard operation
vscode-java-kotlin copied to clipboard

An error occurred while updating the kotlin classpath entry, Project does not exist

Open nisargjhaveri opened this issue 3 years ago • 3 comments

I'm often getting these or similar errors when trying out a project with both Java and Kotlin source. Is is a sample Android project I have with just a couple of files.

[Error - 12:16:13 AM] 28-Nov-2022, 12:16:13 am SampleApplication does not exist
SampleApplication does not exist
Java Model Exception: Error in Java Model (code 969): SampleApplication does not exist
	at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:574)
	at org.eclipse.jdt.internal.core.JavaModelManager.getPerProjectInfoCheckExistence(JavaModelManager.java:2503)
	at org.eclipse.jdt.internal.core.JavaProject.getPerProjectInfo(JavaProject.java:2444)
	at org.eclipse.jdt.internal.core.JavaProject.getRawClasspath(JavaProject.java:2487)
	at org.javacs.kt.jdt.ls.extension.KotlinImporterUtils.setKlsClasspathEntry(KotlinImporterUtils.java:49)
	at org.javacs.kt.jdt.ls.extension.SetKotlinBuildOutputCommandHandler.executeCommand(SetKotlinBuildOutputCommandHandler.java:46)
...
[Error - 12:16:27 AM] 28-Nov-2022, 12:16:27 am An error occurred while updating the kotlin classpath entry

nisargjhaveri avatar Nov 27 '22 19:11 nisargjhaveri

Hey @nisargjhaveri

Are you able to open the project without this extension? I.e., are the kotlin imports in java files the only issue with it?

I tried to set it up, but I couldn't. Note that android support in both vscode-java and vscode-kotlin is limited. If they are not able to build the project, my extension won't be able to help. Keep in mind that the project even has references to symbols that do not exist. If you can give me a simple example application that can be opened in vscode and only exhibits the errors related to the kotlin imports into java code, then I can take a look.

daplf avatar Apr 10 '23 15:04 daplf

Hey! The project was opening fine without this extension (vscode-java has an experimental option to support Android projects, I probably had that enabled).

To add a couple of things which might be useful. The error was intermittent, sometimes the classpath would update correctly for kotlin, sometimes it would give this error. I tried to have a look then, from what I remember this looked like some race condition when we might be trying to insert the classpath before the project was ready.

nisargjhaveri avatar Apr 10 '23 16:04 nisargjhaveri

vscode-java has an experimental option to support Android projects, I probably had that enabled

I did notice this, but for some reason I still couldn't set it up. I'll have to look at it later.

The error was intermittent, sometimes the classpath would update correctly for kotlin, sometimes it would give this error. I tried to have a look then, from what I remember this looked like some race condition when we might be trying to insert the classpath before the project was ready.

If this is the case, then perhaps it's easy to fix, assuming JDT provides the necessary APIs to know if the project is ready.

daplf avatar Apr 10 '23 17:04 daplf