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

Building Java project shows error: "Build failed, do you want to continue?"

Open niiiksh opened this issue 6 years ago • 60 comments

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
  • Operating System: Windows 10 Pro (1709)
  • JDK version: 9.0.4
  • Visual Studio Code version: 1.21.1
  • Java extension version: 0.22.0
Steps To Reproduce
  1. Open attached java project in Visual Studio Code with Java Extensions Pack installed
  2. Start debugging by F5

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.

niiiksh avatar Apr 05 '18 20:04 niiiksh

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?

fbricon avatar Apr 05 '18 23:04 fbricon

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.

niiiksh avatar Apr 06 '18 10:04 niiiksh

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

dedoussis avatar Apr 10 '18 23:04 dedoussis

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.

ovidiup13 avatar Apr 15 '18 00:04 ovidiup13

Same problem here (works perfect in the past, but this problem occures weeks ago by an update!)

jtuttas avatar Apr 19 '18 08:04 jtuttas

Same problem here, hadnt made any changes to the project. Building without problemas in IntelliJ

leandevesa-despegar avatar Apr 19 '18 13:04 leandevesa-despegar

Guys, if you want to help please:

  • check whether cleaning the workspace helps or not (and report it back here)
  • provide sample projects consistently reproducing the problem

fbricon avatar Apr 19 '18 13:04 fbricon

Ok, cleaning workspace seems to have fixed it (at least by now). Can't provide sample project!

Thanks for your help

leandevesa-despegar avatar Apr 19 '18 13:04 leandevesa-despegar

@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

ovidiup13 avatar Apr 19 '18 17:04 ovidiup13

I've deleted the complete workspaceStorage but the problem still there. Attached you will find a small Test Project where the error appears.

error

Well after pressing "Proceed" the code executed normal!

Fiae16i.zip

jtuttas avatar Apr 20 '18 06:04 jtuttas

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 !?!?!

jtuttas avatar Apr 20 '18 07:04 jtuttas

Yeah, I couldn't find any logs whatsoever for the failed build process.

ovidiup13 avatar Apr 21 '18 02:04 ovidiup13

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

wpcfan avatar May 05 '18 08:05 wpcfan

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"
        }
    ]
}

rectcircle avatar May 15 '18 17:05 rectcircle

Maybe your code has error,check it here.This is my case. snipaste_2018-05-18_08-39-09

scriptwang avatar May 18 '18 00:05 scriptwang

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.

davidaorr avatar May 22 '18 00:05 davidaorr

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?

michaelkleinhenz avatar May 25 '18 09:05 michaelkleinhenz

Same Problem. The project is https://github.com/swagger-api/swagger-codegen mvn complie success, but get error when debug image 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"

Theodosia1005 avatar May 25 '18 10:05 Theodosia1005

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.

winstars avatar Jun 12 '18 15:06 winstars

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. 👍

3urdoch avatar Jun 30 '18 14:06 3urdoch

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 avatar Jul 11 '18 12:07 dsyer

@dsyer entirely possible some instructions are stale, but the overall idea of deleting the workspace directory is still valid. We'll look into it

fbricon avatar Jul 11 '18 13:07 fbricon

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 avatar Jul 11 '18 13:07 dsyer

@dsyer it's indeed hard to see which one corresponds to your workspace. So the simplest is to delete the whole directory.

fbricon avatar Jul 11 '18 13:07 fbricon

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

fbricon avatar Jul 11 '18 13:07 fbricon

I had the same issue, and was able to fix it by clearing my workspace directory.

mgasparel avatar Jul 19 '18 13:07 mgasparel

@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.

akshayeshenoi avatar Jul 25 '18 10:07 akshayeshenoi

I'm having the same issue... Cleaning the workspace does not help. Interesting is if a hit proceed it works fine...

augustocdias avatar Aug 03 '18 13:08 augustocdias

@augustocdias What is your VSCode java version?

yaohaizh avatar Aug 03 '18 15:08 yaohaizh

@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 avatar Aug 06 '18 09:08 augustocdias