opencode icon indicating copy to clipboard operation
opencode copied to clipboard

jdtls lsp custom config failed

Open sincebyte opened this issue 3 weeks ago • 4 comments

Description

I have a opencode.json config in the project root dir. and I configed jdtls lsp for my project. when open code run , the cli stack here and output:

➜  skytech git:(dev) opencode --log-level DEBUG --print-logs
INFO  2026-01-13T10:30:36 +363ms service=default version=1.1.10 args=["--log-level","DEBUG","--print-logs"] opencode
INFO  2026-01-13T10:30:36 +1ms service=config path=/Users/van/.config/opencode/config.json loading
INFO  2026-01-13T10:30:36 +1ms service=config path=/Users/van/.config/opencode/opencode.json loading
INFO  2026-01-13T10:30:36 +9ms service=config path=/Users/van/.config/opencode/opencode.jsonc loading

I'm sure the command could start the mcp server, cause I use it in aider-ce, all things works well

{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "bash": "allow",
    "edit": "allow"
  },
  "keybinds": {
    "input_backspace": "backspace,shift+backspace,ctrl+h"
  },
  "tui": {
    "scroll_speed": 3,
    "scroll_acceleration": {
      "enabled": true
    },
    "diff_style": "stacked"
  },
  "lsp": {
    "custom-lsp": {
      "enable": true,
      "command": [
        "mcp-language-server",
        "--workspace",
        "/Users/van/ZY/workspace/skytech/",
        "--lsp",
        "/Users/van/soft/jdk/jdk-21.0.6.jdk/Contents/Home/bin/java",
        " ",
        "-Declipse.application=org.eclipse.jdt.ls.core.id1",
        "-Dosgi.bundles.defaultStartLevel=4",
        "-Declipse.product=org.eclipse.jdt.ls.core.product",
        "-Xms128m",
        "-javaagent:/Users/van/.doom.d/neoemacs/lombok1.18.38.jar",
        "-Djava.import.generatesMetadataFilesAtProjectRoot=false",
        "-jar",
        "/Users/van/lsp-java/plugins/org.eclipse.equinox.launcher_1.7.0.v20250519-0528.jar",
        "-configuration",
        "/Users/van/lsp-java/config_mac",
        "-data",
        "/Users/van/lsp-java-mcp/workspace"
      ],
      "extensions": [".java"]
    }
  }
}

Plugins

no

OpenCode version

1.1.10

Steps to reproduce

copy the config file on a java project root dir .and use opencode.

Screenshot and/or share link

No response

Operating System

macos 26.1 (25B78)

Terminal

iterm2

sincebyte avatar Jan 13 '26 10:01 sincebyte

This issue might be related to existing MCP/LSP server configuration problems. Please check:

  • #8171: MCP Docker servers fail to connect after upgrade from v1.1.6 to v1.1.7+ (similar pattern of servers not connecting after version changes)
  • #8121: MCP timeout not respected (configuration timeout settings not being honored)
  • #8144: OpenCode.exe hangs indefinitely at "Initializing..." with no debug logs (similar hanging behavior during startup with custom configurations)
  • #8126: Opencode fails to launch if it can't write to config (config loading issues causing startup failure)

Your issue appears to be related to custom LSP configuration (jdtls) causing OpenCode to hang during initialization. The related issues above document similar problems with custom server configurations not being properly loaded or connected.

github-actions[bot] avatar Jan 13 '26 10:01 github-actions[bot]

For lombok jdtls you can use

#!/bin/sh
DIR="$HOME/.local/share/opencode/bin/jdtls"
LAUNCHER=$(ls "$DIR/plugins/org.eclipse.equinox.launcher_"*.jar)
LOMBOK_JAR="$DIR/lombok.jar"
WORKSPACE="$HOME/.cache/jdtls/$(echo "$PWD" | md5sum | cut -d' ' -f1)"

exec java \
  -Declipse.application=org.eclipse.jdt.ls.core.id1 \
  -Dosgi.bundles.defaultStartLevel=4 \
  -Declipse.product=org.eclipse.jdt.ls.core.product \
  -Dosgi.checkConfiguration=true \
  -Xms1G -Xmx2G \
  --add-modules=ALL-SYSTEM \
  --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \
  --add-opens java.base/java.util=ALL-UNNAMED \
  --add-opens java.base/java.lang=ALL-UNNAMED \
  --add-opens java.base/java.io=ALL-UNNAMED \
  --add-opens java.base/java.nio=ALL-UNNAMED \
  --add-opens java.base/sun.nio.ch=ALL-UNNAMED \
  --add-opens java.compiler/javax.annotation.processing=ALL-UNNAMED \
  --add-opens java.compiler/javax.lang.model=ALL-UNNAMED \
  --add-opens java.compiler/javax.lang.model.element=ALL-UNNAMED \
  --add-opens java.compiler/javax.lang.model.type=ALL-UNNAMED \
  --add-opens java.compiler/javax.lang.model.util=ALL-UNNAMED \
  --add-opens java.compiler/javax.tools=ALL-UNNAMED \
  -javaagent:"$LOMBOK_JAR" \
  -jar "$LAUNCHER" \
  -configuration "$DIR/config_linux" \
  -data "$WORKSPACE"

Use it with the following configuration:

"lsp": {
    "jdtls": {
      "command": ["/home/<user>/.bin/start_jdtls.sh"],
      "extensions": [".java"]
    }
  }

Just don’t forget to update the Lombok path, or download it to the correct location, to avoid breaking the script.

trethore avatar Jan 13 '26 11:01 trethore

got it , opencode has a mcp server , we just need to startup jdtls.

sincebyte avatar Jan 13 '26 12:01 sincebyte

For lombok jdtls you can use

#!/bin/sh DIR="$HOME/.local/share/opencode/bin/jdtls" LAUNCHER=$(ls "$DIR/plugins/org.eclipse.equinox.launcher_"*.jar) LOMBOK_JAR="$DIR/lombok.jar" WORKSPACE="$HOME/.cache/jdtls/$(echo "$PWD" | md5sum | cut -d' ' -f1)"

exec java
-Declipse.application=org.eclipse.jdt.ls.core.id1
-Dosgi.bundles.defaultStartLevel=4
-Declipse.product=org.eclipse.jdt.ls.core.product
-Dosgi.checkConfiguration=true
-Xms1G -Xmx2G
--add-modules=ALL-SYSTEM
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.compiler/javax.annotation.processing=ALL-UNNAMED
--add-opens java.compiler/javax.lang.model=ALL-UNNAMED
--add-opens java.compiler/javax.lang.model.element=ALL-UNNAMED
--add-opens java.compiler/javax.lang.model.type=ALL-UNNAMED
--add-opens java.compiler/javax.lang.model.util=ALL-UNNAMED
--add-opens java.compiler/javax.tools=ALL-UNNAMED
-javaagent:"$LOMBOK_JAR"
-jar "$LAUNCHER"
-configuration "$DIR/config_linux"
-data "$WORKSPACE" Use it with the following configuration:

"lsp": { "jdtls": { "command": ["/home//.bin/start_jdtls.sh"], "extensions": [".java"] } } Just don’t forget to update the Lombok path, or download it to the correct location, to avoid breaking the script.

unfortunately,failed again. I test the script, it works well. but the script do not execute when opencode startup.

{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "bash": "allow",
    "edit": "allow"
  },
  "keybinds": {
    "input_backspace": "backspace,shift+backspace,ctrl+h"
  },
  "tui": {
    "scroll_speed": 3,
    "scroll_acceleration": {
      "enabled": true
    },
    "diff_style": "stacked"
  },
  "lsp": {
    "jdtls": {
      "command": ["~/ZY/workspace/skytech/start_jdtls.sh"],
      "extensions": [".java"]
    }
  }
}

#!/bin/sh
DIR="/Users/van/lsp-java"
LAUNCHER=$(ls "$DIR/plugins/org.eclipse.equinox.launcher_"*.jar)
LOMBOK_JAR="/Users/van/.doom.d/neoemacs/lombok1.18.38.jar"
WORKSPACE="$HOME/.cache/jdtls/$(echo "$PWD" | md5sum | cut -d' ' -f1)"

exec /Users/van/soft/jdk/jdk-21.0.6.jdk/Contents/Home/bin/java \
  -Declipse.application=org.eclipse.jdt.ls.core.id1 \
  -Dosgi.bundles.defaultStartLevel=4 \
  -Declipse.product=org.eclipse.jdt.ls.core.product \
  -Dosgi.checkConfiguration=true \
  -Xms1G -Xmx2G \
  --add-modules=ALL-SYSTEM \
  --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \
  --add-opens java.base/java.util=ALL-UNNAMED \
  --add-opens java.base/java.lang=ALL-UNNAMED \
  --add-opens java.base/java.io=ALL-UNNAMED \
  --add-opens java.base/java.nio=ALL-UNNAMED \
  --add-opens java.base/sun.nio.ch=ALL-UNNAMED \
  --add-opens java.compiler/javax.annotation.processing=ALL-UNNAMED \
  --add-opens java.compiler/javax.lang.model=ALL-UNNAMED \
  --add-opens java.compiler/javax.lang.model.element=ALL-UNNAMED \
  --add-opens java.compiler/javax.lang.model.type=ALL-UNNAMED \
  --add-opens java.compiler/javax.lang.model.util=ALL-UNNAMED \
  --add-opens java.compiler/javax.tools=ALL-UNNAMED \
  -javaagent:"$LOMBOK_JAR" \
  -jar "$LAUNCHER" \
  -configuration "$DIR/config_mac" \
  -data "$WORKSPACE"

➜ skytech git:(dev) sh start_jdtls.sh WARNING: Using incubator modules: jdk.incubator.vector 1月 13, 2026 9:15:33 下午 org.apache.aries.spifly.BaseActivator log 信息: Registered provider ch.qos.logback.classic.spi.LogbackServiceProvider of service org.slf4j.spi.SLF4JServiceProvider in bundle ch.qos.logback.classic

sincebyte avatar Jan 13 '26 13:01 sincebyte

same on , jdtls [not installed]

CoderXiaohui avatar Jan 13 '26 17:01 CoderXiaohui