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

dap-debug → Attach → open-network-stream wrong-type-argument stringp nil #31

Closed
skybert opened this issue Jan 10, 2019 · 19 comments
Closed

Comments

@skybert
Copy link

skybert commented Jan 10, 2019

Heya,

sorry to bother you again, but dap-java has stopped working for me and I cannot figure out why.
In a working lsp-java project where dap-java has worked pretty well the last month, I now get this whenever I do M-x dap-debug → Attach → 5005:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  make-network-process(:name "localhost(5005)" :buffer nil :host "localhost" :service nil :nowait nil :tls-parameters nil)
  open-network-stream("localhost(5005)" nil "localhost" nil :type plain)
  dap--create-session((:type "java" :request "attach" :hostName "localhost" :port 5005 :host "localhost" :name "localhost(5005)" :debugServer nil :__sessionId "1547123273.6672068"))
  dap-start-debugging((:type "java" :request "attach" :hostName "localhost" :port 5005 :host "localhost" :name "localhost(5005)" :debugServer nil :__sessionId "1547123273.6672068"))
  dap-debug((:type "java" :request "attach" :hostName "localhost" :port 5005 :host "localhost" :name "localhost(5005)" :debugServer nil :__sessionId "1547123273.6672068"))

Output in *Messages*:

10-Jan-2019 13:38:25 >> workspace/executeCommand vscode.java.startDebugSession
Error from the Language Server: No delegateCommandHandler for vscode.java.startDebugSession (Method not Found)
open-network-stream: Wrong type argument: stringp, nil

I've updated the language server with M-x lsp-java-update-server, but vscode.java.startDebugSession is still apparently not available.

Versions:

GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2018-12-14
lsp-java-20181221.1616
lsp-mode-20190105.2044
lsp-ui-20190109.1959
dap-mode-20190109.1841
@yyoncho
Copy link
Member

yyoncho commented Jan 10, 2019

Error from the Language Server: No delegateCommandHandler for vscode.java.startDebugSession (Method not Found)

This means that the debug plugin/bundle is missing.

what does C-: (lsp-java--bundles) returns? Did you try to delete lsp-java-server-install-dir and then call lsp-java-update-server?

Also, inspect the messages buffer when lsp-java is starting, ussually there is an error message if JDT LS fails to load a bundle.

Can you make sure that you are using latest version of dap-mode and you are not hitting #30 ?

@skybert
Copy link
Author

skybert commented Jan 10, 2019

This means that the debug plugin/bundle is missing.

I believe I've encountered that one before. Mhmm. Do I have to do anything extra to get that bundle?

what does C-: (lsp-java--bundles) returns

("/home/torstein/.emacs.d/eclipse.jdt.ls/server/bundles/java.debug.plugin.jar")

Did you try to delete lsp-java-server-install-dir and then call lsp-java-update-server?

Tried that (again), but although *Messages* look good:

10-Jan-2019 15:03:54 Initializing Java Language Server 0.30.0.201812180348
10-Jan-2019 15:03:54 Installed reference:file:/home/torstein/.emacs.d/eclipse.jdt.ls/server/bundles/java.debug.plugin.jar
Init...[Starting]
0% Starting Java Language Server [Starting]
10-Jan-2019 15:03:54 Started reference:file:/home/torstein/.emacs.d/eclipse.jdt.ls/server/bundles/java.debug.plugin.jar
10-Jan-2019 15:03:54 >> initialized
20% Starting Java Language Server [Starting]

I still get:

10-Jan-2019 15:05:01 >> workspace/executeCommand vscode.java.startDebugSession
Error from the Language Server: No delegateCommandHandler for vscode.java.startDebugSession (Method not Found)
open-network-stream: Wrong type argument: stringp, nil

@yyoncho
Copy link
Member

yyoncho commented Jan 10, 2019

Hm, when you do lsp-describe-session and when you expand the jdtls capabilities do you see vscode.java.startDebugSession in the list of commands?

 `-[-] jdtls:5034
    |-[-] Buffers
    |  |-[+] Importer.java
    |  `-[+] ImporterIntegrationTest.java
    `-[-] Capabilities
       |-[-] workspace:
       |  `-[-] workspaceFolders:
       |     |-[X] changeNotifications: t
       |     `-[X] supported: t
       |-[-] executeCommandProvider:
       |  `-[X] commands: (che.jdt.ls.extension.findImplementers vscode.java.fetchUsageData che.jdt.ls.extension.detectTest che.jdt.ls.extension.libraryChildren che.jdt.ls.extension.findTestByCursor che.jdt.ls.extension.findTestFromProject che.jdt.ls.extension.effectivePom che.jdt.ls.extension.mavenProjects che.jdt.ls.extension.externalLibrariesChildren che.jdt.ls.extension.libraryEntry che.jdt.ls.extension.debug.findResourcesByFqn vscode.java.resolveMainClass che.jdt.ls.extension.usages che.jdt.ls.extension.reImportMavenProject che.jdt.ls.extension.plain.createProject che.jdt.ls.extension.refactoring.rename.validate.new.name che.jdt.ls.extension.outputDir org.eclipse.che.jdt.ls.extension.filestructure vscode.java.buildWorkspace che.jdt.ls.extension.import.organizeImports java.project.listSourcePaths che.jdt.ls.extension.refactoring.move.validate che.jdt.ls.extension.refactoring.move.command vscode.java.resolveClasspath che.jdt.ls.extension.plain.getProjectSourceLocations java.project.updateSourceAttachment che.jdt.ls.extension.configuration.updatePreferences che.jdt.ls.extension.refactoring.move.verify.destination che.jdt.ls.extension.findTestFromEntry che.jdt.ls.extension.externalLibraries che.jdt.ls.extension.classpathTree che.jdt.ls.extension.plain.sourceFolders java.project.resolveSourceAttachment vscode.java.startDebugSession che.jdt.ls.extension.plain.updateClasspath java.project.addToSourcePath che.jdt.ls.extension.pom.diagnostics che.jdt.ls.extension.updateWorkspace che.jdt.ls.extension.libraryContentURL che.jdt.ls.extension.resolveClasspath che.jdt.ls.extension.findTestInFile che.jdt.ls.extension.refactoring.move.get.destinations.command che.jdt.ls.extension.configuration.updateJavaCoreOptions che.jdt.ls.extension.refactoring.rename.get.linked.elements che.jdt.ls.extension.findTestFromFolder java.edit.organizeImports java.project.removeFromSourcePath che.jdt.ls.extension.refactoring.rename che.jdt.ls.extension.configuration.getPreferences che.jdt.ls.extension.refactoring.rename.get.type che.jdt.ls.extension.plain.addJarsToClassPath che.jdt.ls.extension.libraryContentByPath che.jdt.ls.extension.configuration.getJavaCoreOptions vscode.java.updateDebugSettings che.jdt.ls.extension.debug.identifyFqnInResource)
       |-[-] renameProvider:
       |  `-[X] prepareProvider: t
       |-[-] documentOnTypeFormattingProvider:
       |  |-[X] moreTriggerCharacter: (

@skybert
Copy link
Author

skybert commented Jan 10, 2019

Mhmm. I cannot expand anything, it just says:

[X] ~/src/my-project

and that's it.

@yyoncho
Copy link
Member

yyoncho commented Jan 12, 2019

Hm, this is odd.

There is dap-mode test that covers this functionality (attaching to remote target) and at this point it is green.

Clone the repo and install cask:

cask install
cask exec ecukes --timeout 60 features/JUnit.feature

@yyoncho
Copy link
Member

yyoncho commented Jan 14, 2019

I was about to setup a new debian machine for testing and I hit the exactly the same issue - it is caused by using OpenJDK - after I switched to Oracle version the issue was fixed.

@skybert
Copy link
Author

skybert commented Jan 15, 2019

Thanks for figuring out that one.

So is this a bug or a missing feature? lsp-java works with OpenJDK, so IMHO dap-mode should too. But this has perhaps nothing to do with dap-mode itself, but the debug plugin to the Eclipse server?

@yyoncho
Copy link
Member

yyoncho commented Jan 15, 2019

It is something related to JDT LS/Che JDT LS/Java Debug Adapter/OpenJDK version. You may run

@yyoncho
Copy link
Member

yyoncho commented Oct 19, 2019

Is this still relevant?

@skybert
Copy link
Author

skybert commented Oct 21, 2019

I'll change my config to use OpenJDK 11 and use it for a day. Then I'll report back.

@skybert
Copy link
Author

skybert commented Oct 22, 2019

I haven't encountered this again when running on OpenJDK 11, no. Admittedly I only debug JUnit tests, but if they both call vscode.java.startDebugSession, it should be safe to assume the issue has been resolved?

@yyoncho
Copy link
Member

yyoncho commented Oct 22, 2019

I think so.

Offtopic: As a side note, I think that you are going to take part of Emacs conf? If this is so and if you are going to present lsp-java/dap-mode I will be happy to provide feedback on your agenda and eventually solve issues that bother you.

@yyoncho yyoncho closed this as completed Oct 22, 2019
@skybert
Copy link
Author

skybert commented Oct 22, 2019

Hi @yyoncho,

yes, I will do a wee presentation at Emacs Conf (10 min). In the demo I've prepared I plan to show:

Code navigation

Works.

Jump to source of 3rd party libraries

Works.

Auto completion

Works.

Import classes

Works.

Static import methods and fields

Works well for single imports, replacing the current one, but I don't
dare to use the replace all function as this sometimes deletes code
it shouldn't.

Not a big issue for my demo, though, just FYI.

Run JUnit tests from within Emacs

Works.

Linting

  • Unused variables
  • Wrong syntax
  • Missing generics

Works.

Implement missing class

Works, but I will not show it because lsp-java often has problems
recognising that the class is indeed present. Often (always?) I must
do a mvn clean install on the project for the new class to work
everywhere. Reloading the file revert-buffer also makes lsp-java
recognise the new class (but I believe dap still will fail).

Interestingly, code navigation to the new class works just
fine. Still, both the linting and dap-mode fails because it "doesn't exist".

The behaviour is easy enough to reproduce (at least for me, using my
.emacs) using the branch feature/empty-shop here:
https://gitlab.com/skybert/cheese-shop/tree/feature/empty-shop/
My .emacs is here: https://gitlab.com/skybert/my-little-friends/blob/master/emacs/.emacs

In CheeseShop, add Customer customer = new Customer() and then
have lsp-java create Customer for you. You can navigate to
Customer from CheeseShop, but flycheck will mark Customer as
undefined and dap-java-run-test-class will fail.

Implement missing method

Works.

Debug application from within Emacs

Works.

Debugger with conditional break points

Works. (one of my favourite features in dap-mode)

Refactoring: rename variable

Works, but has sometimes the same problem as Implement missing class, code navigation to the new method name works, but the classes
using the method on the object mark it as undefined.

Other things

In addition comes things that aren't lsp-java/dap-mode specifc, but helps create an awesome java development environment in Emacs.

What do you think?

@yyoncho
Copy link
Member

yyoncho commented Oct 22, 2019

I think that some of the issues that you are seeing are caused either by dap not doing a build before running something(which is a bug that I should fix) or caused by the fact you have disabled file watches. I believe some of them could be fixed with lsp-java-build-project which you should call from time to time when the watches are disabled.

Refactorings: I think you could demo inline/extract method/variable(my favourites).

You may include lsp-treemacs stuff like: https://github.com/emacs-lsp/lsp-treemacs#lsp-treemacs-deps-list

There is a lot of stuff to demo though, 10 minutes wouldn't be enough.

  1. dap-ui-repl
  2. dap-hydra
  3. spring boot support
  4. XML language server is great for editing pom.xml

but I don't dare to use the replace all function as this sometimes deletes code
it shouldn't.

When you hit issues like these, please go ahead and report them. I think most of them are JDT LS issues and they are very responsive. You may be hitting: eclipse-jdtls/eclipse.jdt.ls#1203

FYI I am working on support of java test extension:
Screenshot at 2019-10-22 22-49-51

@skybert
Copy link
Author

skybert commented Oct 26, 2019

I think that some of the issues that you are seeing are caused either by dap not doing a build before running something(which is a bug that I should fix) or caused by the fact you have disabled file watches.

I've enabled lsp-enable-file-watchers t, but the problem of not recognising newly created classes persists.

I didn't think of tryinglsp-java-build-project as this always fails on my "real" projects. In cheese-shop it works, but not for newly created interface (I introduced Customer extends Visitor and had lsp create Visitor for me.

inline/extract method/variable

These are really nice! I definitely want to include those.

I didn't discover them because they don't show up until you've selected the region. For extract to method, I understand that you want the user to have selected the region, but for extract to variable, it should IMO work when you're just on the same line:

|foo.getList();

where extract to variable gives:

Foo foo2 = foo;
foo2.getList();

Which isn't useful to me. What I'd expect (the way IDEA works):

Foo foo = foo.getList();

You may include lsp-treemacs stuff

Good idea. I've included the deps browser, the symbols browser and the error browser in my demo.

It looks grand. Is there a way to scale the icons according to text height? They're a bit too big in my setup:

(set-face-attribute 'default nil
                            :family "Source Code Pro"
                            :height 100
                            :weight 'normal
                            :width 'normal)

When you hit issues like these, please go ahead and report them.

Thanks for the reminder.

FYI I am working on support of java test extension:

So cool!

Talking about tests. Is there away to use the JUnit 4 test runner and not JUnit5/Vintage for Junit4 tests? dap can't run any of the tests in a couple of my projects with both 4 and 5 on the classpath.

@yyoncho
Copy link
Member

yyoncho commented Oct 26, 2019

I didn't think of tryinglsp-java-build-project as this always fails on my "real" projects. In cheese-shop it works, but not for newly created interface (I introduced Customer extends Visitor and had lsp create Visitor for me.

I will try it on my side.

|foo.getList();

Place the cursor on ; and you will endup with what you want. But yeah, still I consider this as a bug of JDT LS, havent reported it yet to the server(e. g. it should extract even when you are on List.

When you hit issues like these, please go ahead and report them.
Thanks for the reminder.

To elaborate a bit more - everything that does not work flawlessly should be reported. I am not con

It looks grand. Is there a way to scale the icons according to text height? They're a bit too big in my setup:

I use

  (add-hook 'treemacs-mode-hook
            (lambda () (treemacs-resize-icons 15)))

Talking about tests. Is there away to use the JUnit 4 test runner and not JUnit5/Vintage for Junit4 tests? dap can't run any of the tests in a couple of my projects with both 4 and 5 on the classpath.

The new test runner I am writing now will distinguish junit 4/5/testng and it will solve that issue. But still, IMO we should solve the issue for the current runner(e. g. report it upstream or introduce separate command for junit4/junit5 on our side). We should start with a but report on our side.

@yyoncho
Copy link
Member

yyoncho commented Oct 26, 2019

In cheese-shop it works, but not for newly created interface (I introduced Customer extends Visitor and had lsp create Visitor for me.

I tested on my side and I was unable to reproduce it. Do you do save all files after you create the new class? I think that if you call mvn clean install you save the files and the issue goes away not because of the mvn invocation but because of saving the project file before compilation.

@skybert
Copy link
Author

skybert commented Oct 31, 2019

Heya,

sorry for the late reply.

To elaborate a bit more - everything that does not work flawlessly should be reported. I am not con

I like your attitude.

treemacs-resize-icons 15

Thanks, that looks a bit better. Still think some icons (the one with white background for java files and the yellow for warnings) are a tad too cartoonish, but I guess that's what icon themes are for 😄

Place the cursor on ; and you will endup with what you want.

Thanks for the tip. That works.

Do you do save all files after you create the new class?

Yes, that seems (so far) to solve all my problems with new classes and interfaces. It's much smoother now that I know this caveat.

@yyoncho
Copy link
Member

yyoncho commented Oct 31, 2019

Thanks, that looks a bit better. Still think some icons (the one with white background for java files and the yellow for warnings) are a tad too cartoonish, but I guess that's what icon themes are for

Yes - I have used the icons from vscode - we will do all-the-icons theme one day - emacs-lsp/lsp-treemacs#18

Yes, that seems (so far) to solve all my problems with new classes and interfaces. It's much smoother now that I know this caveat.

Good.

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

No branches or pull requests

2 participants