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

cannot evaluate because of java.lang.IllegalStateException: Cannot evaluate, please specify projectName in launch.json.. #843

Open
lucian0c opened this issue Jul 14, 2020 · 16 comments

Comments

@lucian0c
Copy link

I cannot evaluate an expression in VSCode debugging tomcat.

I have this error.
cannot evaluate because of java.lang.IllegalStateException: Cannot evaluate, please specify projectName in launch.json..

My launch.json

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"projectName": "My API",
"request": "launch",
"mainClass": "${file}"
}
]
}

Environment
  • Operating System: Windows 10
  • JDK version: 11
  • Visual Studio Code version: 1.46.1
  • Java extension version: v0.9.1
  • Java Debugger extension version: v0.26.0

Is there anything else that i should change in my launch.json?

@testforstephen
Copy link
Contributor

I cannot evaluate an expression in VSCode debugging tomcat.

Could you share your steps to launch the tomcat and connect to the debugger?

@lucian0c
Copy link
Author

I cannot evaluate an expression in VSCode debugging tomcat.

Could you share your steps to launch the tomcat and connect to the debugger?

Tomcat: Start Tomcat Server
Tomcat: Debug on tomcat server: And i choose my war file

@testforstephen
Copy link
Contributor

OK, you're using Tomcat for Java extension to launch debugging. That extension doesn't consume the local launch.json config. Could you take a look at a new extension https://marketplace.visualstudio.com/items?itemName=redhat.vscode-server-connector, it has better support for tomcat server.

@lucian0c
Copy link
Author

Where should it be the launch.json?

The extension that you mention it's not for tomcat, at least it doesn't name it on the supporte list of servers.

@lucian0c
Copy link
Author

Sorry, i read that is supported, at least minimal requriements. I will check, thanks.

@no-response
Copy link

no-response bot commented Aug 18, 2020

This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Aug 18, 2020
@lucian0c
Copy link
Author

How can i help to get this fix? I add as many information as i could. Could it be a test case? Is easy to reproduce it.

@no-response no-response bot reopened this Aug 25, 2020
@testforstephen
Copy link
Contributor

If you want the case is covered well, at least you should provide detailed reproduce steps and a minimum sample project to reproduce the issue.

@MikeZTM
Copy link

MikeZTM commented Aug 26, 2020

I have same issue and can create a test case.

servlet URL GET:
http://127.0.0.1:8080/WSJson/test

test1.zip

when VScode open the folder with two projects it can not evaluate any thing.
If I only start VScode with one project it will work as usual.

I need to debug something in the dependency project so I hope this can be fixed.

@halboffen
Copy link

halboffen commented Oct 29, 2020

Had a similar problem. In my case the solution was to use exactly the same project name as in the file .project. Then it did work.

@robstryker
Copy link

Hi:

For any newcomers experiencing this issue, an above comment suggests using vscode-server-connector extension instead of the tomcat extension. The actual name of the extension is vscode-community-server-connector.

https://marketplace.visualstudio.com/items?itemName=redhat.vscode-community-server-connector

The other extension (vscode-server-connector) has support for Red Hat servers and runtimes, NOT Tomcat. Please use the community extension instead.

@Cornstar23
Copy link

@robstryker The community extension works with tomcat as you point out, but I still have the same issue as OP.

@robstryker
Copy link

We've had one user report a similar issue here: redhat-developer/rsp-server-community#85

No real solution was found but some of the comments from the user provide a workaround.

@codebling
Copy link

codebling commented Mar 14, 2022

Right-click on a Java file (one without a main() function) and choose "Run Java" and you'll get a prompt with a few options. This prompt will show the project name.

pop-up menu when Java file is not executable

As you can see in this screenshot of this Ant project, sometimes the project name is unpredictable.

See also this answer on StackOverflow

@Damith88
Copy link

in my case I ended up using Eclipse for debugging. VS code java debugging sucks

@croniser
Copy link

I was able to remove this error by deleting the projectName property:
{
"type": "java",
"name": "Debug (Test)",
"request": "attach",
"hostName": "localhost",
"port": 5005
}

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

9 participants