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

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

Open lucian0c opened this issue 4 years ago • 15 comments

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?

lucian0c avatar Jul 14 '20 19:07 lucian0c

I cannot evaluate an expression in VSCode debugging tomcat.

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

testforstephen avatar Jul 15 '20 03:07 testforstephen

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

lucian0c avatar Jul 15 '20 12:07 lucian0c

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.

testforstephen avatar Jul 16 '20 04:07 testforstephen

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 avatar Jul 16 '20 12:07 lucian0c

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

lucian0c avatar Jul 16 '20 12:07 lucian0c

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[bot] avatar Aug 18 '20 07:08 no-response[bot]

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.

lucian0c avatar Aug 25 '20 03:08 lucian0c

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.

testforstephen avatar Aug 25 '20 03:08 testforstephen

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.

MikeZTM avatar Aug 26 '20 17:08 MikeZTM

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.

halboffen avatar Oct 29 '20 20:10 halboffen

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.

robstryker avatar Mar 09 '21 21:03 robstryker

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

Cornstar23 avatar Apr 07 '21 20:04 Cornstar23

We've had one user report a similar issue here: https://github.com/redhat-developer/rsp-server-community/issues/85

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

robstryker avatar Apr 07 '21 21:04 robstryker

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

codebling avatar Mar 14 '22 01:03 codebling

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

Damith88 avatar Sep 18 '23 12:09 Damith88