Skip to content

Failed to resolve classpath: xyz #331

Closed

Description

In launch mode, the debugger will auto resolve the classpath based on the given mainClass and projectName, but the mechanism is often error-prone. Especially when user configure a wrong the mainClass or projectName, it will throw the errors:

  • Failed to resolve classpath: Main class '.*' doesn't exist in the workspace.
  • Failed to resolve classpath: The project '.*' is not a valid java project.
  • Failed to resolve classpath: Main class '.*' isn't unique in the workspace, please pass in specified projectname.

It's better to add pre-validation mechanism to prompt user about the configuration error.

Activity

  1. testforstephen commented on Jul 27, 2018

    @testforstephen
    ContributorAuthor

    CJ Bailey (@cjbailey) Migrate your comment to another bug #344

  2. cjbailey commented on Jul 27, 2018

    @cjbailey

    Thanks. I've deleted my comment from here.

  3. changed the title [-]Failed to resolve classpath: xxx[/-] [+]Failed to resolve classpath: xyz[/+] on Jul 31, 2018
  4. testforstephen commented on Aug 3, 2018

    @testforstephen
    ContributorAuthor

    For the error case Failed to resolve classpath: Main class '.*' isn't unique in the workspace, please pass in specified projectname., one possible reason is the search engine caching stale classes. When Java debugger try to search the corresponding project for the specified fully qualified class name, it will cause multiple projects returned. To solve this problem, need keep the search engine always sync with disk files.

  5. testforstephen commented on Aug 28, 2018

    @testforstephen
    ContributorAuthor

    The feature #355 covered most of cases about fail to resolve classpath. Keep this issue open to track the edge case.

  6. testforstephen commented on Sep 20, 2019

    @testforstephen
    ContributorAuthor

    This issue has been fixed, close it.

  7. rajinder-yadav commented on Oct 25, 2021

    @rajinder-yadav

    I am seeing this issue. I created 3 maven java projects,

    1. basic-arrays
    2. hello-world
    3. strings

    and added each to the workspace, when I try to run the 2nd project I created, I see this error.

    Screenshot_20211024_220046

    If I go into each project folder, open vscode, each project compiles and run fine.

    To create the projects from vscode

    shift+ctrl+p -> java: create project -> maven -> maven-archetype-quickstart

    At then end make sure to select, "add to workspace" (you can use shift+ctrl+p to add it later also).

    Version: 1.62.0-insider
    Commit: 34eeebdd66033633ac22efd5fab928ae37916168
    Date: 2021-10-15T05:15:40.814Z
    Electron: 13.5.1
    Chrome: 91.0.4472.164
    Node.js: 14.16.0
    V8: 9.1.269.39-electron.0
    OS: Linux x64 5.14.11-2-default

  8. rajinder-yadav commented on Oct 25, 2021

    @rajinder-yadav

    I created a few more project, the error is gone but it's running the wrong project, even when I have the main java file open and I click on "Run", as you can see from the output in the Terminal.
    Screenshot_20211024_222040

  9. testforstephen commented on Oct 25, 2021

    @testforstephen
    ContributorAuthor

    Could you try to clean the workspace?

    F1 -> Java: Clean Java Language Server Workspace

    If that doesn't work, please open a new issue and provide a sample project to help reproduce the issue.

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions