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

Fails with "java.net.Socket cannot be cast to class java.lang.String" #40

Open
holyjak opened this issue Dec 11, 2019 · 9 comments
Open
Labels

Comments

@holyjak
Copy link

holyjak commented Dec 11, 2019

I want to connect to a remote nREPL server but the invocation fails:

deps.edn:

{:aliases {:repl {:extra-deps {nrepl/nrepl {:mvn/version "0.6.0"} 
                                              nrepl/drawbridge {:mvn/version "0.2.1"}}
           :main-opts  ["-m" "nrepl.cmdline" "--connect" "--transport" 
                               "drawbridge.client/ring-client-transport" 
                               "--port" "55555" "--host"]}}}

command:

clojure -Arepl 10.199.227.33

output:

Execution error (ClassCastException) at clj-http.client/parse-url (client.clj:175).
class java.net.Socket cannot be cast to class java.lang.String (java.net.Socket and java.lang.String are in module java.base of loader 'bootstrap')

See the full output from clojure in this gist: https://gist.github.com/holyjak/7a644ef57bc17807ac18d22d820bbda7

Environment

  • Amazon Linux 2 or OSX
  • JVM java-11-amazon-corretto.x86_64 or java-1.8.0-openjdk

It is quite likely I do something wrong but I have no idea what :(

It works with lein

Using leiningen 2.9 and project.clj:

(defproject repl-client-drawbridge "0.1.0-SNAPSHOT"
  :plugins [[nrepl/drawbridge "0.2.1"]])

this works:

$ lein repl :connect http://10.199.227.33:55555
Connecting to nREPL at http://10.199.227.33:55555
REPL-y 0.4.3, nREPL 0.6.0
Clojure 1.10.1
OpenJDK 64-Bit Server VM 11.0.1+13
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>
@holyjak holyjak changed the title Fails with "java.net.Socket cannot be cast to class java.lang.String" under java 11 Fails with "java.net.Socket cannot be cast to class java.lang.String" Dec 11, 2019
@bbatsov
Copy link
Contributor

bbatsov commented Dec 12, 2019

Looking at the stacktrace, it seems to me some conversion is missing. Probably Lein does it somewhere, but we don't do it in the built-in CLI.

@Bost
Copy link

Bost commented Dec 21, 2020

The problem persists:

$ clj -Sdeps '{:deps {nrepl/drawbridge {:mvn/version "0.2.1"}}}' \
    -m nrepl.cmdline --transport drawbridge.client/ring-client-transport \
    --connect --host localhost --port 5050
WARNING: When invoking clojure.main, use -M
nREPL 0.8.3
Clojure 1.10.1
OpenJDK 64-Bit Server VM 11.0.9.1+1-Ubuntu-0ubuntu1.20.10
Interrupt: Control+C
Exit:      Control+D or (exit) or (quit)
Execution error (ClassCastException) at clj-http.client/parse-url (client.clj:170).
class java.net.Socket cannot be cast to class java.lang.String (java.net.Socket and java.lang.String are in module java.base of loader 'bootstrap')

Full report at:
/tmp/clojure-7424303235548335896.edn

And the clj-http.client/parse-url line 170 is here https://github.com/dakrone/clj-http/blob/24d195596b6f1ace411f1a3690526338fca9e331/src/clj_http/client.clj#L170


Dear Santa 🎅!

The 2020 wasn't that much of a fun. We'll call it quits if you help us make this bug 🐞 go disappear.

PS: Just in case... we know where ❄️️​ you live! #globalwarming

@bbatsov bbatsov added the bug label Dec 21, 2020
@Bost
Copy link

Bost commented Dec 22, 2020

Interestingly enough, it doesn't work properly with the latest leiningen.

Old leiningen 2.9.0:

$ lein version
Leiningen 2.9.0 on Java 11.0.9.1 OpenJDK 64-Bit Server VM
$ lein repl :connect http://localhost:5555/repl
Connecting to nREPL at http://localhost:5555/repl
REPL-y 0.4.3, nREPL 0.6.0
Clojure 1.10.1
OpenJDK 64-Bit Server VM 11.0.9.1+1-Ubuntu-0ubuntu1.20.10
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>

Current 2.9.5:

$ lein version
Leiningen 2.9.5 on Java 11.0.9.1 OpenJDK 64-Bit Server VM
$ lein repl :connect http://localhost:5555/repl
Connecting to nREPL at http://localhost:5555/repl

and it doesn't go past this point.

@bbatsov
Copy link
Contributor

bbatsov commented Dec 22, 2020

Don't have much time for Drawbridge these days, so any help with debugging the problem would be appreciated. I'm assuming the problem with the latest lein might be related to the use of a newer version of nREPL, although I can't think of any particular change that might break this.

@bbatsov
Copy link
Contributor

bbatsov commented Dec 22, 2020

Does this work with Lein 2.9.4?

@Bost
Copy link

Bost commented Dec 22, 2020

It works with 2.9.3 and does NOT work with 2.9.4. Here's a little script to test it with different leiningens:

#!/usr/bin/env bash

versions=(
    '2.9.3'
    '2.9.4'
    # '2.9.5'
)

mkdir ~/bin/

for ver in "${versions[@]}"; do
    wget -O ~/bin/lein-$ver https://raw.githubusercontent.com/technomancy/leiningen/$ver/bin/lein
    chmod +x ~/bin/lein-$ver
    lein-$ver repl :connect http://localhost:5555/repl
    # press Ctrl-C for the next iteration
done

Sorry that I didn't bisect it straight away it was past 3 a.m.

@bbatsov
Copy link
Contributor

bbatsov commented Dec 22, 2020

Got it. Then it's likely something to do with nREPL 0.7. //cc @shen-tian

@jeaye
Copy link

jeaye commented Dec 18, 2021

@Bost Did you find a solution to this? I'm seeing it with lein 2.9.5. The client is flooding GET requests, but the repl never fully connects.

I've verified 2.9.3 works (thanks so much for finding that).

@bbatsov
Copy link
Contributor

bbatsov commented Dec 18, 2021

Perhaps overriding the default nREPL version will fix the problem?

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

No branches or pull requests

4 participants