mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
979 stars 62 forks source link

Java Remote Debug stopped working after upgrading #620

Closed degerhar7 closed 3 months ago

degerhar7 commented 5 months ago

LSP client configuration

local config = {
  flags = {
    debounce_text_changes = 80,
  },
  capabilities = capabilities,
  on_attach = on_attach,
  init_options = {
    bundles = bundles
  },
  root_dir = root_dir,
  settings = {
    java = {
      format = {
        settings = {
          url = home .. "/.local/share/eclipse/eclipse-java-google-style.xml",
          profile = "GoogleStyle",
        },
      },
      signatureHelp = { enabled = true },
      contentProvider = { preferred = 'fernflower' },
      completion = {
        favoriteStaticMembers = {
          "org.hamcrest.MatcherAssert.assertThat",
          "org.hamcrest.Matchers.*",
          "org.hamcrest.CoreMatchers.*",
          "org.junit.jupiter.api.Assertions.*",
          "java.util.Objects.requireNonNull",
          "java.util.Objects.requireNonNullElse",
          "org.mockito.Mockito.*"
        },
        filteredTypes = {
          "com.sun.*",
          "io.micrometer.shaded.*",
          "java.awt.*",
          "jdk.*",
          "sun.*",
        },
      },
      sources = {
        organizeImports = {
          starThreshold = 9999;
          staticStarThreshold = 9999;
        },
      },
      codeGeneration = {
        toString = {
          template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}"
        },
        hashCodeEquals = {
          useJava7Objects = true,
        },
        useBlocks = true,
      },
      configuration = {
        runtimes = {
          {
            name = "OpenJDK-11",
            path = "/usr/lib/jvm/java-11-openjdk",
          },
          {
            name = "OpenJDK-21",
            path = "/usr/lib/jvm/java-21-openjdk",
          },
        }
      }
    }
  },
  cmd = {
    "/usr/lib/jvm/java-21-openjdk/bin/java",
    '-Declipse.application=org.eclipse.jdt.ls.core.id1',
    '-Dosgi.bundles.defaultStartLevel=4',
    '-Declipse.product=org.eclipse.jdt.ls.core.product',
    '-Dlog.protocol=true',
    '-Dlog.level=ALL',
    '-Xmx4g',
    '--add-modules=ALL-SYSTEM',
    '--add-opens', 'java.base/java.util=ALL-UNNAMED',
    '--add-opens', 'java.base/java.lang=ALL-UNNAMED',
    '-javaagent:' .. home .. '/.local/share/eclipse/lombok.jar',
    '-jar', vim.fn.glob('/usr/share/java/jdtls/plugins/org.eclipse.equinox.launcher_*.jar'),
    '-configuration', home .. '/.config/aur_jdtls/config_linux',
    '-data', workspace_folder,
  },
}

Eclipse.jdt.ls version

1.32.0-1

Steps to Reproduce

  1. Create a .vscode/launch.json file:
{
      "configurations": [
          {
              "type": "java",
              "request": "attach",
              "name": "Launch Debug Java",
              "hostName": "192.168.3.5",
              "port": 8787
          }
      ]
}
  1. Add breakpoint in NeoVim (Leader + bb)
  2. Continue Debugger (Leader +dc)

Expected Result

Successful connection to remote JVM

Actual Result

Error executing vim.schedule lua callback: ...rhar/.local/share/nvim/lazy/nvim-jdtls/lua/jdtls/dap.lua:49: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
        [C]: in function 'ipairs'
        ...rhar/.local/share/nvim/lazy/nvim-jdtls/lua/jdtls/dap.lua:49: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1393: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
mfussenegger commented 4 months ago

I improved the error handling in that area a bit with: https://github.com/mfussenegger/nvim-jdtls/pull/621

I suspect your project has compile errors/missing dependencies or something. The error you saw happened when it couldn't resolve the classpath.