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

Portkey only works with java 8, not 9 or 10. #43

Open
MageMasher opened this issue Apr 19, 2018 · 3 comments
Open

Portkey only works with java 8, not 9 or 10. #43

MageMasher opened this issue Apr 19, 2018 · 3 comments

Comments

@MageMasher
Copy link

asciicast

The issue has to do with Ouroboros not being able to instrument the jvm. I tried to highlight the issue but apparently asciinema doesn't display tmux output. Below is the stack trace.

 ~/programming/git_repos/portkey/examples/ring-app   master  lein repl
Preparing for self instrumentation.
#error {
 :cause Can not attach to current VM
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message java.lang.reflect.InvocationTargetException, compiling:(portkey/ouroboros.clj:177:1)
   :at [clojure.lang.Compiler load Compiler.java 7526]}
  {:type java.lang.reflect.InvocationTargetException
   :message nil
   :at [jdk.internal.reflect.NativeMethodAccessorImpl invoke0 NativeMethodAccessorImpl.java -2]}
  {:type java.io.IOException
   :message Can not attach to current VM
   :at [sun.tools.attach.HotSpotVirtualMachine <init> HotSpotVirtualMachine.java 75]}]
 :trace
 [[sun.tools.attach.HotSpotVirtualMachine <init> HotSpotVirtualMachine.java 75]
  [sun.tools.attach.VirtualMachineImpl <init> VirtualMachineImpl.java 58]
  [sun.tools.attach.AttachProviderImpl attachVirtualMachine AttachProviderImpl.java 58]
  [com.sun.tools.attach.VirtualMachine attach VirtualMachine.java 207]
  [jdk.internal.reflect.NativeMethodAccessorImpl invoke0 NativeMethodAccessorImpl.java -2]
  [jdk.internal.reflect.NativeMethodAccessorImpl invoke NativeMethodAccessorImpl.java 62]
  [jdk.internal.reflect.DelegatingMethodAccessorImpl invoke DelegatingMethodAccessorImpl.java 43]
  [java.lang.reflect.Method invoke Method.java 564]
  [portkey.ouroboros$eval3126 invokeStatic ouroboros.clj 186]
  [portkey.ouroboros$eval3126 invoke ouroboros.clj 177]
  [clojure.lang.Compiler eval Compiler.java 7062]
  [clojure.lang.Compiler load Compiler.java 7514]
  [clojure.lang.RT loadResourceScript RT.java 379]
  [clojure.lang.RT loadResourceScript RT.java 370]
  [clojure.lang.RT load RT.java 460]
  [clojure.lang.RT load RT.java 426]
  [clojure.core$load$fn__6550 invoke core.clj 6047]
  [clojure.core$load invokeStatic core.clj 6046]
  [clojure.core$load doInvoke core.clj 6030]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [clojure.core$load_one invokeStatic core.clj 5849]
  [clojure.core$load_one invoke core.clj 5844]
  [clojure.core$load_lib$fn__6495 invoke core.clj 5889]
  [clojure.core$load_lib invokeStatic core.clj 5888]
  [clojure.core$load_lib doInvoke core.clj 5869]
  [clojure.lang.RestFn applyTo RestFn.java 142]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$load_libs invokeStatic core.clj 5926]
  [clojure.core$load_libs doInvoke core.clj 5910]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$require invokeStatic core.clj 5948]
  [clojure.core$require doInvoke core.clj 5948]
  [clojure.lang.RestFn invoke RestFn.java 805]
  [portkey.core$eval3059$loading__6436__auto____3060 invoke core.clj 1]
  [portkey.core$eval3059 invokeStatic core.clj 1]
  [portkey.core$eval3059 invoke core.clj 1]
  [clojure.lang.Compiler eval Compiler.java 7062]
  [clojure.lang.Compiler eval Compiler.java 7051]
  [clojure.lang.Compiler load Compiler.java 7514]
  [clojure.lang.RT loadResourceScript RT.java 379]
  [clojure.lang.RT loadResourceScript RT.java 370]
  [clojure.lang.RT load RT.java 460]
  [clojure.lang.RT load RT.java 426]
  [clojure.core$load$fn__6550 invoke core.clj 6047]
  [clojure.core$load invokeStatic core.clj 6046]
  [clojure.core$load doInvoke core.clj 6030]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [clojure.core$load_one invokeStatic core.clj 5849]
  [clojure.core$load_one invoke core.clj 5844]
  [clojure.core$load_lib$fn__6495 invoke core.clj 5889]
  [clojure.core$load_lib invokeStatic core.clj 5888]
  [clojure.core$load_lib doInvoke core.clj 5869]
  [clojure.lang.RestFn applyTo RestFn.java 142]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$load_libs invokeStatic core.clj 5926]
  [clojure.core$load_libs doInvoke core.clj 5910]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$require invokeStatic core.clj 5948]
  [clojure.core$require doInvoke core.clj 5948]
  [clojure.lang.RestFn invoke RestFn.java 436]
  [dev$eval158$loading__6436__auto____159 invoke dev.clj 1]
  [dev$eval158 invokeStatic dev.clj 1]
  [dev$eval158 invoke dev.clj 1]
  [clojure.lang.Compiler eval Compiler.java 7062]
  [clojure.lang.Compiler eval Compiler.java 7051]
  [clojure.lang.Compiler load Compiler.java 7514]
  [clojure.lang.RT loadResourceScript RT.java 379]
  [clojure.lang.RT loadResourceScript RT.java 370]
  [clojure.lang.RT load RT.java 460]
  [clojure.lang.RT load RT.java 426]
  [clojure.core$load$fn__6550 invoke core.clj 6047]
  [clojure.core$load invokeStatic core.clj 6046]
  [clojure.core$load doInvoke core.clj 6030]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [clojure.core$load_one invokeStatic core.clj 5849]
  [clojure.core$load_one invoke core.clj 5844]
  [clojure.core$load_lib$fn__6495 invoke core.clj 5889]
  [clojure.core$load_lib invokeStatic core.clj 5888]
  [clojure.core$load_lib doInvoke core.clj 5869]
  [clojure.lang.RestFn applyTo RestFn.java 142]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$load_libs invokeStatic core.clj 5926]
  [clojure.core$load_libs doInvoke core.clj 5910]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$require invokeStatic core.clj 5948]
  [clojure.core$require doInvoke core.clj 5948]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [user$eval15 invokeStatic form-init6730845369384340559.clj 1]
  [user$eval15 invoke form-init6730845369384340559.clj 1]
  [clojure.lang.Compiler eval Compiler.java 7062]
  [clojure.lang.Compiler eval Compiler.java 7051]
  [clojure.lang.Compiler eval Compiler.java 7051]
  [clojure.lang.Compiler load Compiler.java 7514]
  [clojure.lang.Compiler loadFile Compiler.java 7452]
  [clojure.main$load_script invokeStatic main.clj 278]
  [clojure.main$init_opt invokeStatic main.clj 280]
  [clojure.main$init_opt invoke main.clj 280]
  [clojure.main$initialize invokeStatic main.clj 311]
  [clojure.main$null_opt invokeStatic main.clj 345]
  [clojure.main$null_opt invoke main.clj 342]
  [clojure.main$main invokeStatic main.clj 424]
  [clojure.main$main doInvoke main.clj 387]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.lang.Var applyTo Var.java 702]
  [clojure.main main main.java 37]]}
nREPL server started on port 58436 on host 127.0.0.1 - nrepl://127.0.0.1:58436
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.9.0-beta1
Java HotSpot(TM) 64-Bit Server VM 10.0.1+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

dev=>
@viesti
Copy link
Collaborator

viesti commented Apr 20, 2018

This is similar to clojure-goes-fast/clj-memory-meter#1 (comment), so:

JVM_OPTS=-Djdk.attach.allowAttachSelf=true lein repl

gets to the next step, which is:

CompilerException java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader, compiling:(core.clj:249:3)
user=> *e
#error {
 :cause "java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader"
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message "java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader, compiling:(core.clj:249:3)"
   :at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3700]}
  {:type java.lang.ClassCastException
   :message "java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader"
   :at [portkey.core$fn__17864 invokeStatic "core.clj" 253]}]
 :trace

So we need to catch up with changes to classloader hierarchy in Java9.

@viesti
Copy link
Collaborator

viesti commented Apr 20, 2018

Then again, Lambda runtime is based on Java8, so it's best to use Java8 for Clojure Lambdas for now.

@cgrand
Copy link
Collaborator

cgrand commented Apr 27, 2018

for future ref: some avoid the flag by launching a helper process raphw/byte-buddy#295

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

3 participants