Open niiiksh opened 6 years ago
this sample project builds without errors on my mac. I can run the Main class, although it stops because it can't connect to the socket, but that's irrelevant to this problem.
The log you attached references a bunch of classes that are not present in your sample.
message: Helper cannot be resolved;code: 570425394
message: Device cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: Helper cannot be resolved;code: 570425394
message: Device cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a variable;code: 33554515
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: Device cannot be resolved to a type;code: 16777218
Are those classes yours? Have you tried cleaning up the workspace directory?
This is all the classes from my another project. I don't know why they are here, maybe they compiled in shared folder but that was unwanted behavior.
Get exactly the same error when I try to build/debug a Java project of mine. After proceeding, the project seems to have been built fine. IntelliJ is also not throwing any errors when I build.
Environment Operating System: Mac OS X El Capitan JDK version: 8 Update 161 Visual Studio Code version: 1.21.1 Java extension version: 0.22.0
Any updates on this? I am having the same issue.
Builds fine from the command line. It's only when running VS Code Debug this occurs.
Same problem here (works perfect in the past, but this problem occures weeks ago by an update!)
Same problem here, hadnt made any changes to the project. Building without problemas in IntelliJ
Guys, if you want to help please:
Ok, cleaning workspace seems to have fixed it (at least by now). Can't provide sample project!
Thanks for your help
@fbricon That seems to have solved it for me as well!
I don't have a sample project to share unfortunately.
However, I think this issue appeared right after update to VS Code 1.22.1
I've deleted the complete workspaceStorage but the problem still there. Attached you will find a small Test Project where the error appears.
Well after pressing "Proceed" the code executed normal!
Ok, solved it, the problem caused by a compile error in the Java Code. If I compile the code on the terminal the error was reported and I can fix it.
But why are compile errors not reported by the extension in the problem tab !?!?!
Yeah, I couldn't find any logs whatsoever for the failed build process.
Run into same error, please clone https://github.com/wpcfan/gtm.git
and cd backend
-> code .
, if we debug the project, the error will show up
Get exactly the same error when I try to debug a Maven Java project of mine (Ubuntu18.04). "Build Failed".
"Build Failed" will not display when I save my workspace as a file
Temporary solution
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch)-ProviderUserApplication<microservice-simple-provider-user>",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopOnEntry": false,
"preLaunchTask": "package", //package before debug
"mainClass": "com.itmuch.cloud.study.ProviderUserApplication",
"projectName": "microservice-simple-provider-user",
"args": ""
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "package",
"type": "shell",
"command": "mvn package",
"group": "build"
},
{
"label": "test",
"type": "shell",
"command": "mvn -B test",
"group": "test"
}
]
}
Maybe your code has error,check it here.This is my case.
I am getting this same error. I have a maven project that builds fine from the command line, and if I press the "Proceed" button will debug correctly.
Same here. Cleaning up the workspace did not help. Project compiles fine on command line. No errors shown on the trace console in vscode.
The project is a multi-module project that includes an Android submodule (which I don't care about when using vscode). I know that Android projects are not supported by the extension. I tried to exclude the Android submodule from the vscode context (using files.exclude), but the Java extension seems not to support this. The directory in the project basically vanishes from view, but is still checked and issues appearing in the warnings list.
The language server log shows:
!ENTRY org.eclipse.jdt.ls.core 4 0 2018-05-25 10:57:21.048
!MESSAGE Error occured while building workspace. Details:
message: The project was not built since its build path is incomplete. Cannot find the class file for android.os.Handler. Fix the build path then try building this project;code: 0
message: The type android.os.Handler cannot be resolved. It is indirectly referenced from required .class files;code: 16777540
..which is expected (I think) due to the missing Android support.
So I think this is a feature request: it should be possible to exclude modules/directories for the language server.
This also does not work and makes no difference:
"java.import.exclusions": [
"**/android/**"
Is there any way of excluding a directory from the language server?
Same Problem. The project is https://github.com/swagger-api/swagger-codegen mvn complie success, but get error when debug Maven and jdk version Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:05+08:00) Maven home: C:\apache-maven-3.5.3\bin.. Java version: 1.8.0_172, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.8.0_172\jre Default locale: en_US, platform encoding: GBK OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Same Problem too. Yet it looks like to be fixed on my problem. 1.I tried to change the jdk.home path from jdk10 to jdk 8, and it works fine!!!! 2.I have tried to clean the workspace before, but nothing changed. 3.maven on my vscode is working fine, compiling is also good, but vscode java debug is always failed.
I have been tearing my hear out with this issue, clearing the workspace has fixed it for me.
I was getting lots of errors related to another project. I can't recall but the other project was a project i used as a template for this one, so it was either that those files were at one time in the workspace and were no-longer, or I had previously opened that project with VS code.
Either way, that the time, the files were not in the workspace any more but the build was showing errors relating to them, deleting the workspace completely solved the issue but its obviously not a permanent fix as it could return. It seems the workspace is keeping residual class/java files behind that are no-longer relevant.
For now, I can continue without the build error. So i'm happy. 👍
Is the wiki out of date? The "cleaning the workspace" instructions don't seem to make sense any more (there's nothing that says "Executing ..." anywhere in the developer tools console).
@dsyer entirely possible some instructions are stale, but the overall idea of deleting the workspace directory is still valid. We'll look into it
Thanks. I can see the workspace storage directories, but I don't have a way to know which one is relevant to my current workspace. Also, maybe you could clarify what "clean" means? Is it literally just "delete the whole directory"?
@dsyer it's indeed hard to see which one corresponds to your workspace. So the simplest is to delete the whole directory.
but I guess we can change the directory naming scheme to add the current folder name as a suffix to the path hash, to make it easier to identify
I had the same issue, and was able to fix it by clearing my workspace directory.
@dsyer @fbricon The instructions are indeed stale. However if you open the Java Language Server logs (> Java: Open Java Language Server log file
), you can find -data
flag somewhere in the file.
Deleting everything in the workspaceStorage/
folder did help. Make sure you reload your window after doing it though.
I'm having the same issue... Cleaning the workspace does not help. Interesting is if a hit proceed it works fine...
@augustocdias What is your VSCode java version?
@yaohaizh sorry for taking too long to reply. I'm using the latest stable versions for all. All extensions updated and also latest stable VSCode
@augustocdias Could you help share your server log for this issue?
@yaohaizh It stopped happening and I have no idea what have I done :|
We have pushed a fix https://github.com/eclipse/eclipse.jdt.ls/commit/091dbb4ab5d17fb2c2d806e51974639fd7ae73bd for this last week, not sure if this is related.
+1
This issue is easy to replicate on windows. Cleaning up workspace helps sometimes but does not last, usually on second build attempt the issue returns. I am using v 0.32.0 on Windows 10.
This error seems to appear for me in case I have several maven projects with the same classes. Each maven project located in different folder and the folder then added to workspace,
Make sure that Maven is the build framework used in .Project
One cause of the issue could be that a framework other than maven is actually used for the build. so when building using maven from the command line it works fine, but when trying to debug the other build framework configured in .project is then used and therefore it doesn't build.
I guess you are trying to compile a .java file in a folder hierarchy where other .java files exist and have errors. check your "problems" tab and see if there are any. if so, the project will probably show the error message until all problems are resolved. After that you should stop getting the "Build failed..." Message.
@alexeykazakov What's your vscode & vscode java extension version?
The first time I added a Java project to my workspace, a pop-up came up asking if I wanted to exclude extension-generated project settings files (.project, .classpath, .factorypath, .settings) from the file explorer. I clicked Yes, for this workspace (or something similar). After I kept getting the build error message, I tried the following:
I cleaned the workspace, then created a fresh workspace. I added a Java project to it, and when the popup came up, I selected Never. I then ran the debugger and I no longer got the message.
Edit: The project I tested with was a fresh one created by Maven (maven-archetype-quickstart), it had no project settings files in it before adding it to the workspace.
I see this problem a lot of times. Is it possible to skip the check somehow? In 99% of the time, everything is actually fine..
Disabling it would help for now..
@john-dev Change the user setting to"java.debug.settings.forceBuildBeforeLaunch": false
, which will disable the check before run/debug.
oh i was looking for that setting, thanks @testforstephen
I am able to reliable reproduce this problem by having both Maven and Gradle build files present in the solution. If I remove the gradle files (just by renaming them to bak.*) and perform a "Java: Clean the java language server workspace" and restarting, the issue goes away. Re-introducing the gradle files triggers the issue again.
I don't know enough (yet) about the maven or gradle, or the VS Code java extensions to understand why or if there is a way to allow both to co-exist peacefully.
@colin-young Gradle project import takes precedence over Maven's. You can decide to disable the Gradle project import by adding "java.import.gradle.enabled": false
to your .vscode/settings.json file
Just verify that you already added the tag <package>jar</package>
to your pom.xml
Here's another data point. I had this "Build failed..." issue in a workspace that was running Theia with (by mistake) both @theia/java
and this extension (vscode-java
) installed as a plugin. One of them tripped over the other the whole time, and in the end everything would work, but only after the annoying error message. Removing @theia/java
and @theia/java-debug
fixed it.
For me, the problem was caused by other files in the open folder that could not compile.
So this issue was popping up in my recently installed vs code wih jdk 14 with a basic Hello World program too. I changed the directory and it is now working, but with this written on it.
cd 'e:\try'; & 'c:\Users\lkshk\.vscode\extensions\vscjava.vscode-java-debug-0.28.0\scripts\launcher.bat' 'C:\Program Files\Java\jdk-14.0.1\bin\java.exe' '-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:50466' '--enable-preview' '-XX:+ShowCodeDetailsInExceptionMessages' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\lkshk\AppData\Roaming\Code\User\workspaceStorage\0185ec8187bc148d9a8a20b77ca120e5\redhat.java\jdt_ws\try_7906d541\bin' 'Runner' so this is working perfectly
Same issue.How could I get over with this problem.
Building Java project shows error: "Build failed, do you want to continue?" when the build is actually completed because when I click "Proceed" it will run updated version of my code and autobuild enabled when I type new code. javatest.zip
Environment
Steps To Reproduce
javatest.zip
.log
Current Result
Build error
Expected Result
No error
Additional Informations
I have another project built with this extension and it builds without any error.