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

Java extension does not work on standalone java files #2231

Closed
randombck4r opened this issue Nov 26, 2021 · 8 comments · Fixed by #2234
Closed

Java extension does not work on standalone java files #2231

randombck4r opened this issue Nov 26, 2021 · 8 comments · Fixed by #2234

Comments

@randombck4r
Copy link

Environment
  • Operating System: Windows 10
  • JDK version: 17.0.1
  • Visual Studio Code version: 1.62.3
  • Java extension version: 1.1.0
Steps To Reproduce
  1. Open any .java file
  2. Switch to standard mode

logs:
TypeError: Cannot read property 'fsPath' of undefined
at C:\Users\Username\.vscode\extensions\redhat.java-1.1.0\dist\extension.js:2:801280
at Object.t.prepareExecutable (C:\Users\Username\.vscode\extensions\redhat.java-1.1.0\dist\extension.js:2:801967)
at t.StandardLanguageClient. (C:\Users\Username\.vscode\extensions\redhat.java-1.1.0\dist\extension.js:2:859054)
at Generator.next ()
at s (C:\Users\Username\.vscode\extensions\redhat.java-1.1.0\dist\extension.js:2:856724)

Current Result

Language server starts in lightweight mode automatically while it should start in standard mode.
Switching to standard mode manually gives an error message: "command 'java.runtimeValidation.open' already exists".

Additional Informations

If a folder is opened in vscode then the language server will start in standard mode and will work just fine.
Version 1.0.0 and older work as well.

@mozhuanzuojing
Copy link

@randombck4r could you share your settings.json

@randombck4r
Copy link
Author

@randombck4r could you share your settings.json

{ "editor.insertSpaces": false, "java.home": "D:\\Tools\\Java\\jdk-17.0.1", "java.configuration.runtimes": [ { "name": "JavaSE-11", "path": "D:\\Tools\\Java\\jdk-11.0.11+9", }, { "name": "JavaSE-17", "path": "D:\\Tools\\Java\\jdk-17.0.1", "default": true }, ], "editor.cursorSmoothCaretAnimation": true, "editor.suggestSelection": "first", "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", "files.exclude": { "**/.classpath": true, "**/.project": true, "**/.settings": true, "**/.factorypath": true }, "workbench.colorTheme": "Default Light+", "workbench.colorCustomizations": { "activityBar.border": "#d7d7d7", "activityBar.background": "#f3f3f3", "activityBar.foreground": "#2c2c2c" }, "security.workspace.trust.untrustedFiles": "open", "editor.semanticHighlighting.enabled": true }

@randombck4r randombck4r reopened this Nov 27, 2021
@chaitanyabiswas
Copy link

Yes, for me also it's not working.
the older version is working fine.

@francisco-zr
Copy link

Same here, i can't compile a single file with this version, needed to rollback to 1.0

@mozhuanzuojing
Copy link

mozhuanzuojing commented Nov 29, 2021

@randombck4r cannot reproduce

image

this is my settings.json

{
    "workbench.iconTheme": "vscode-icons",
    // 控制编辑器是否从"快速打开"中打开,以预览显示。预览编辑器在固定之前会重复使用(例如,通过双击或编辑)。
    "workbench.editor.enablePreviewFromQuickOpen": true,
    "files.encoding": "utf8",
    "files.autoGuessEncoding": true,
    "files.exclude": {
        "**/node_modules": false,
        "**/.class": true,
        "**/.settings": true,
        "**/.factorypath": true,
        "**/.classpath": true,
        "**/.project": true
    },
    "editor.tabSize": 4,
    "editor.quickSuggestions": {
        "other": true,
        "comments": false,
        "strings": true
    },
    "editor.snippetSuggestions": "top",
    // vscode默认启用了根据文件类型自动设置tabsize的选项
    "editor.detectIndentation": false,
    "editor.suggestSelection": "first",
    "git.path": "C:/Program Files/Git/bin/git.exe",
    "git.autofetch": true,
    "git.confirmSync": false,
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-1.8",
            "path": "C:/Program Files/RedHat/java-1.8.0-openjdk-1.8.0.275-1"
        },
        {
            "name": "JavaSE-16",
            "path": "C:/Program Files/Eclipse Foundation/jdk-17.0.0.35-hotspot"
        },
        {
            "name": "JavaSE-17",
            "path": "C:/Program Files/Eclipse Foundation/jdk-17.0.0.35-hotspot",
            "default": true
        }
    ],
    // Defines the type filters. All types whose fully qualified name matches the selected filter strings will be ignored in content assist or quick fix proposals and when organizing imports. For example 'java.awt.*' will hide all types from the awt packages.
	"java.completion.filteredTypes": [
		"java.awt.*",
		// "com.sun.*",
		"sun.*",
		"jdk.*",
		"org.graalvm.*",
		"io.micrometer.shaded.*"
	],
    // Use Gradle from the 'gradle-wrapper.properties' file.
    "java.import.gradle.wrapper.enabled": true,
    // Use Gradle from the specified local installation directory or GRADLE_HOME if the Gradle wrapper is missing or disabled and no 'java.import.gradle.version' is specified.
    // Setting for GRADLE_USER_HOME.
    "java.import.gradle.user.home": "D:/java/gradlehome",
    "java.import.gradle.java.home": "C:/Program Files/Eclipse Foundation/jdk-17.0.0.35-hotspot",
    "java.home": "C:/Program Files/Eclipse Foundation/jdk-17.0.0.35-hotspot",
    "java.configuration.maven.userSettings": "D:/java/apache-maven-3.8.3/conf/settings.xml",
    "java.maven.downloadSources": true,
    // "java.import.gradle.jvmArguments": "-XX:+UseShenandoahGC -Xms1g -Xmx4g",
    // Default Java version. -Dlog.level=ALL 
    "java.jdt.ls.vmargs": " -Dsun.jnu.encoding=gb18030 -Dfile.encoding=gb18030  -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes='' -Djdk.attach.allowAttachSelf=true -XX:+UseShenandoahGC -Xms1g -Xmx4g -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true  -XX:ReservedCodeCacheSize=1g -XX:SoftRefLRUPolicyMSPerMB=50 -XX:-OmitStackTraceInFastThrow ",
    "java.format.settings.url": "file:///C:/Users/Administrator/AppData/Roaming/Code/User/vscode-java-google-style.xml",
    "java.settings.url": "file:///C:/Users/Administrator/AppData/Roaming/Code/User/org.eclipse.jdt.core.prefs",
    "java.completion.guessMethodArguments": true,
    "java.configuration.updateBuildConfiguration": "interactive",
    "java.showBuildStatusOnStart.enabled": true,
    // Excludes files and folders from being refreshed by the Java Language Server, which can improve the overall performance. For example, ["node_modules",".git"] will exclude all files and folders named 'node_modules' or '.git'. Defaults to ["node_modules",".git"].
	"java.project.resourceFilters": [
		"node_modules",
		".sql",
		"multipage-2111",
		".git"
	],
    // 针对 [java] 语言,配置替代编辑器设置。
    "[java]": {
        "editor.defaultFormatter": "redhat.java",
        "files.encoding": "gb18030",
        "files.autoGuessEncoding": true
    },
    "java.project.importOnFirstTimeStartup": "automatic",
    "java.debug.settings.onBuildFailureProceed": true,
    "java.debug.settings.vmArgs": "-Xms1g -Xmx4g",
    "java.import.exclusions": [
        "**/org.eclipse.jdt.ls.tests/projects",
        "**/testprojects/**",
        "**/node_modules",
    ],
    "java.maxConcurrentBuilds": 8,
    "java.eclipse.downloadSources": true,
    "java.contentProvider.preferred": "procyon",
    "java.decompiler.cache": true,
    "maven.executable.path": "D:/java/apache-maven-3.8.3/bin/mvn.cmd",
    "maven.terminal.useJavaHome": true,
    "maven.pomfile.autoUpdateEffectivePOM": true,
    "maven.terminal.customEnv": [
        {
            "environmentVariable": "MAVEN_OPTS",
            "value": " -DarchetypeCatalog=internal -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 "
        }
    ],
    // 指定搜索 Maven 项目时要排除的文件夹。
    "maven.excludedFolders": [
        "**/node_modules",
        "**/.*",
        "**/target",
        "**/bin"
    ],
    "search.followSymlinks": false,
    "search.exclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/dist": true,
        "**/bin": true,
        "**/.class": true,
        "/patch": true,
        "**/*.code-search": true
    },
    // 是否在每行末尾添加分号
    "prettier.semi": true,
    "prettier.printWidth": 200, // 超过最大值换行
    // 每个制表符占用的空格数
    "prettier.tabWidth": 4,
    "prettier.bracketSpacing": true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }"
    "emmet.triggerExpansionOnTab": true,
    // 控制资源管理器是否在打开文件时自动显示并选择。
    "explorer.autoReveal": false,
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "explorer.confirmDelete": false,
    "debug.terminal.clearBeforeReusing": true,
    "[jsonc]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "update.enableWindowsBackgroundUpdates": false,
    "update.mode": "manual",
    "java.debug.settings.showQualifiedNames": false,
    "security.workspace.trust.untrustedFiles": "open",
    "[json]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "vsicons.dontShowNewVersionMessage": true,
    "explorer.confirmDragAndDrop": false,
    "editor.fontLigatures": true,
    "editor.lineHeight": 0,
    "redhat.telemetry.enabled": true,
    "[svelte]": {
        "editor.defaultFormatter": "svelte.svelte-vscode"
    },
    "editor.fontFamily": "'Cascadia Code','方正兰亭黑简体', Consolas, 'Courier New', monospace",
    "prettier.trailingComma": "none",
    "svelte.enable-ts-plugin": true,
    "svelte.plugin.svelte.format.config.printWidth": 200,
    "svelte.plugin.svelte.format.config.singleQuote": true,
    "editor.letterSpacing": 0.2,
    "java.configuration.maven.globalSettings": "D:/java/apache-maven-3.8.3/conf/settings.xml",
    "terminal.integrated.confirmOnExit": "always",
    "prettier.spaceBeforeFunctionParen": true,
    "[xml]": {
        "editor.defaultFormatter": "redhat.vscode-xml",
        "files.encoding": "gb18030",
        "files.autoGuessEncoding": true
    },
    "editor.foldingImportsByDefault": false,
    "java.codeGeneration.generateComments": true,
    "editor.largeFileOptimizations": false,
    "editor.bracketPairColorization.enabled": true,
    "java.signatureHelp.enabled": false,
    "gitlens.codeLens.enabled": false,
    "workbench.startupEditor": "none",
    "java.debug.settings.hotCodeReplace": "auto",
    "[sql]": {
        "files.encoding": "utf8"
    },
    "[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "debug.console.acceptSuggestionOnEnter": "on",
    "java.trace.server": "verbose"
}

@rgrunber
Copy link
Member

I suspect this might be due to https://github.com/redhat-developer/vscode-java/pull/2085/files#diff-2d9ec606b265a83596a734df153c4ef01523700dc2576dcf1a80c9092c14d6d3R114 . We should be using storagePath as that is set to handle the case where no workspace is opened.

If I can confirm it, I can push a change soon.

rgrunber added a commit to rgrunber/vscode-java that referenced this issue Nov 29, 2021
- When no workspace is opened, storageUri will be null, but
  workspacePath will be within the temporary storage location
- Fix redhat-developer#2231

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
rgrunber added a commit that referenced this issue Nov 29, 2021
- When no workspace is opened, storageUri will be null, but
  workspacePath will be within the temporary storage location
- Fix #2231

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
@rgrunber rgrunber added this to the Early December milestone Nov 29, 2021
@rgrunber
Copy link
Member

We should have a release to include this by early December, but you can try out https://download.jboss.org/jbosstools/jdt.ls/staging/java-1.2.0-470.vsix until then, and also to confirm it resolves the issue.

@mrrobot97
Copy link

I face the same issue which cause the plugin 'Debugger for java' not working. Downgrade plugin version to v1.0.0 fix the problem.

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

Successfully merging a pull request may close this issue.

7 participants