SNePS / CSNePS

The CSNePS Knowledge Representation and Reasoning System
Other
27 stars 9 forks source link

Error on launch: "java.lang.IllegalArgumentException: Key must be integer" #2

Open martinodb opened 6 years ago

martinodb commented 6 years ago

Hello. I'm trying to use CSNePS, but I'm getting error messages on launch. I've tried snepsgui.sh, sneps.sh and also "lein run", with the same result. The error message is as follows:

$ ./csneps.sh 
java.lang.IllegalArgumentException: Key must be integer
 at clojure.lang.APersistentVector.assoc (APersistentVector.java:345)
    clojure.lang.APersistentVector.assoc (APersistentVector.java:18)
    clojure.lang.RT.assoc (RT.java:792)
    clojure.core$assoc__4371.invokeStatic (core.clj:191)
    clojure.core$update_in.invokeStatic (core.clj:5950)
    clojure.core$update_in.doInvoke (core.clj:5939)
    clojure.lang.RestFn.applyTo (RestFn.java:146)
    clojure.core$apply.invokeStatic (core.clj:652)
    clojure.core$update_in.invokeStatic (core.clj:5949)
    clojure.core$update_in.doInvoke (core.clj:5939)
    clojure.lang.RestFn.invoke (RestFn.java:467)
    cider_nrepl.plugin$middleware.invokeStatic (plugin.clj:54)
    cider_nrepl.plugin$middleware.invoke (plugin.clj:17)
    clojure.lang.Var.invoke (Var.java:379)
    leiningen.core.project$apply_middleware.invokeStatic (project.clj:750)
    leiningen.core.project$apply_middleware.invoke (project.clj:743)
    clojure.core.protocols$fn__6755.invokeStatic (protocols.clj:167)
    clojure.core.protocols/fn (protocols.clj:124)
    clojure.core.protocols$fn__6710$G__6705__6719.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invokeStatic (protocols.clj:31)
    clojure.core.protocols$fn__6738.invokeStatic (protocols.clj:75)
    clojure.core.protocols/fn (protocols.clj:75)
    clojure.core.protocols$fn__6684$G__6679__6697.invoke (protocols.clj:13)
    clojure.core$reduce.invokeStatic (core.clj:6545)
    clojure.core$reduce.invoke (core.clj:6527)
    leiningen.core.project$apply_middleware.invokeStatic (project.clj:745)
    leiningen.core.project$apply_middleware.invoke (project.clj:743)
    leiningen.core.project$activate_middleware.invokeStatic (project.clj:777)
    leiningen.core.project$activate_middleware.invoke (project.clj:773)
    leiningen.core.project$init_project.invokeStatic (project.clj:902)
    leiningen.core.project$init_project.invoke (project.clj:892)
    leiningen.core.project$read.invokeStatic (project.clj:973)
    leiningen.core.project$read.invoke (project.clj:970)
    leiningen.core.project$read.invokeStatic (project.clj:974)
    leiningen.core.project$read.invoke (project.clj:970)
    leiningen.core.main$_main$fn__5998.invoke (main.clj:397)
    leiningen.core.main$_main.invokeStatic (main.clj:394)
    leiningen.core.main$_main.doInvoke (main.clj:391)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.lang.Var.invoke (Var.java:379)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.core$apply.invokeStatic (core.clj:646)
    clojure.main$main_opt.invokeStatic (main.clj:314)
    clojure.main$main_opt.invoke (main.clj:310)
    clojure.main$main.invokeStatic (main.clj:421)
    clojure.main$main.doInvoke (main.clj:384)
    clojure.lang.RestFn.invoke (RestFn.java:436)
    clojure.lang.Var.invoke (Var.java:388)
    clojure.lang.AFn.applyToHelper (AFn.java:160)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)

I'm using the latest unmodified git cloned version:

 git log
commit cfa25695fd2117a1ab71e99219b94cef49692de4
Author: Daniel R. Schlegel <drschleg@buffalo.edu>
Date:   Sat Jan 20 16:42:55 2018 -0500

    Missing channels built in cases where semtypes weren't subtypes, but were compatible, at build time.

Thanks in advance!

digitalneoplasm commented 6 years ago

Hmm, that actually looks like it could be a Leiningen issue - which version of it are you using? My environment is:

$ lein --version Leiningen 2.8.1 on Java 9.0.1 Java HotSpot(TM) 64-Bit Server VM

I did just notice there was an issue compiling some of the Java files on Java 9, and have pushed an update for that to my current dev branch:

https://github.com/SNePS/CSNePS/tree/semtype-objectlang

so you might try that branch too.

martinodb commented 6 years ago

Hey, thanks for the quick reply.

OK, this is interesting. My Leiningen version was 2.7.1 (just to clarify, I checked it was working well with some other Clojure projects, only had problems with CSNePS AFAIK), so I upgraded and now it's 2.8.1. In another project's repo, I can do a "lein --version" to check:

 $ lein --version
Leiningen 2.8.1 on Java 1.8.0_171 OpenJDK 64-Bit Server VM

(Yes, the Java version is outdated, but I updated it and still no luck. More below.)

Now when I run "lein --version" in the SNePS repo, I don't get those errors, but instead I get the following:

 lein --version
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.

I've just checked that it happens both branches, that is in master and in semtype-objectlang.

$ lein --version
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.
$ git branch
* master
  semtype-objectlang
$ git checkout semtype-objectlang 
M   csneps.sh
M   csnepsgui.sh
Switched to branch 'semtype-objectlang'
Your branch is up-to-date with «origin/semtype-objectlang».
 $ lein --version
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.

Here's a desciption in the Leiningen FAQ. I guess it shouldn't happen:

https://github.com/technomancy/leiningen/blob/master/doc/FAQ.md

So, I updateted from Java 8 to Java 10, which should support Java 9 programs, then I upgraded Leiningen again, and tried it in my own Clojure projects to check that it works:

$ lein --version
Leiningen 2.8.1 on Java 10.0.1 Java HotSpot(TM) 64-Bit Server VM

I get the same result I got right after upgrading Leiningen without upgrading Java (that is, no more "Key must be integer" error, but a new warning about "insecure HTTP"):

$ lein --version
Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.Tried to use insecure HTTP repository without TLS.
This is almost certainly a mistake; however in rare cases where it's
intentional please see `lein help faq` for details.

Also checked in both branches (master and semtype-objectlang).

I'm a bit lost here. So what should I try next?

Cheers.

digitalneoplasm commented 6 years ago

Ah! Yes, this is something Leiningen has started doing in the name of security. Add these three lines to the beginning of the project.clj file:

(require 'cemerick.pomegranate.aether) (cemerick.pomegranate.aether/register-wagon-factory! "http" #(org.apache.maven.wagon.providers.http.HttpWagon.))

This will allow it to use plain http repositories, instead of requiring https. I believe one of the libraries I'm using refers to some artifact that is only on one of these repositories which for some reason does not use https. At some point I plan to go through and re-evaluate which of these external libraries I really want to be using... Some which are deeply integrated (like JUNG) haven't been updated in many years now.

Let me know if that does or doesn't fix it up :)

martinodb commented 6 years ago

OK, so now the "insecure HTTP" is gone, but we are back to the "Key must be integer" error:

$ lein --version
java.lang.IllegalArgumentException: Key must be integer
 at clojure.lang.APersistentVector.assoc (APersistentVector.java:345)
    clojure.lang.APersistentVector.assoc (APersistentVector.java:18)
    clojure.lang.RT.assoc (RT.java:792)
    clojure.core$assoc__4371.invokeStatic (core.clj:191)
    clojure.core$update_in.invokeStatic (core.clj:5950)
    clojure.core$update_in.doInvoke (core.clj:5939)
    clojure.lang.RestFn.applyTo (RestFn.java:146)
    clojure.core$apply.invokeStatic (core.clj:652)
    clojure.core$update_in.invokeStatic (core.clj:5949)
    clojure.core$update_in.doInvoke (core.clj:5939)
    clojure.lang.RestFn.invoke (RestFn.java:467)
    cider_nrepl.plugin$middleware.invokeStatic (plugin.clj:54)
    cider_nrepl.plugin$middleware.invoke (plugin.clj:17)
    clojure.lang.Var.invoke (Var.java:379)
    leiningen.core.project$apply_middleware.invokeStatic (project.clj:801)
    leiningen.core.project$apply_middleware.invoke (project.clj:794)
    clojure.core.protocols$fn__6755.invokeStatic (protocols.clj:167)
    clojure.core.protocols/fn (protocols.clj:124)
    clojure.core.protocols$fn__6710$G__6705__6719.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invokeStatic (protocols.clj:31)
    clojure.core.protocols$fn__6738.invokeStatic (protocols.clj:75)
    clojure.core.protocols/fn (protocols.clj:75)
    clojure.core.protocols$fn__6684$G__6679__6697.invoke (protocols.clj:13)
    clojure.core$reduce.invokeStatic (core.clj:6545)
    clojure.core$reduce.invoke (core.clj:6527)
    leiningen.core.project$apply_middleware.invokeStatic (project.clj:796)
    leiningen.core.project$apply_middleware.invoke (project.clj:794)
    leiningen.core.project$activate_middleware.invokeStatic (project.clj:828)
    leiningen.core.project$activate_middleware.invoke (project.clj:824)
    leiningen.core.project$init_project.invokeStatic (project.clj:952)
    leiningen.core.project$init_project.invoke (project.clj:942)
    leiningen.core.project$read.invokeStatic (project.clj:1023)
    leiningen.core.project$read.invoke (project.clj:1020)
    leiningen.core.project$read.invokeStatic (project.clj:1024)
    leiningen.core.project$read.invoke (project.clj:1020)
    leiningen.core.main$_main$fn__4734.invoke (main.clj:416)
    leiningen.core.main$_main.invokeStatic (main.clj:411)
    leiningen.core.main$_main.doInvoke (main.clj:408)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.lang.Var.invoke (Var.java:379)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.core$apply.invokeStatic (core.clj:646)
    clojure.main$main_opt.invokeStatic (main.clj:314)
    clojure.main$main_opt.invoke (main.clj:310)
    clojure.main$main.invokeStatic (main.clj:421)
    clojure.main$main.doInvoke (main.clj:384)
    clojure.lang.RestFn.invoke (RestFn.java:436)
    clojure.lang.Var.invoke (Var.java:388)
    clojure.lang.AFn.applyToHelper (AFn.java:160)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)

As usual, I checked again that Leiningen is working, in another Clojure project:

 $ lein --version
Leiningen 2.8.1 on Java 10.0.1 Java HotSpot(TM) 64-Bit Server VM

Just to clarify, I copy-pasted the code you posted at the beginning of the project.clj file, so that now it starts like this:

(require 'cemerick.pomegranate.aether)
(cemerick.pomegranate.aether/register-wagon-factory!
"http" #(org.apache.maven.wagon.providers.http.HttpWagon.))

(defproject Sneps3-Clojure "1.0.0-SNAPSHOT"

I did this small change in both branches of my forked version of CSNePS. I tested the change on both branches. Same result.

martinodb commented 6 years ago

UPDATE: I found the problem! I had to remove, in my "~/.lein/profiles.clj", these two lines related to CIDER:

[cider/cider-nrepl "0.15.1"]
[refactor-nrepl "2.3.1"]

It's no big deal because I'm not using CIDER anyway. Still it would be interesting if you can confirm the issue. Maybe I can try with more recent versions of those two.

This is my "profiles.clj" once corrected:

{:user
  {:plugins [
     ;; [cider/cider-nrepl "0.15.1"]
     ;; [refactor-nrepl "2.3.1"]
     [lein-ns-dep-graph "0.2.0-SNAPSHOT"]]}
   :dependencies [
     [alembic "0.3.2"]
     [org.clojure/tools.nrepl "0.2.12"]]}

{:dev {:source-paths ["dev" "src" "test"]
         :dependencies [[org.clojure/tools.namespace "0.2.11"]]}}

Oh, one more thing, I only got it to work in the branch semtype-objectlang, not in master.

$ git branch         
* master
  semtype-objectlang
$ ./csnepsgui.sh 
Compiling 3 source files to /home/(...)/SNEPS/CSNePS-forked/CSNePS/target/classes
/home/(...)/SNEPS/CSNePS-forked/CSNePS/src/jvm/edu/buffalo/cse/sneps3/gui/ComparableTreeNode.java:23: error: no suitable method found for sort(Vector<TreeNode>)
        Collections.sort(this.children);
                   ^
    method Collections.<T#1>sort(List<T#1>) is not applicable
      (inference variable T#1 has incompatible bounds
        equality constraints: TreeNode
        upper bounds: Comparable<? super T#1>)
    method Collections.<T#2>sort(List<T#2>,Comparator<? super T#2>) is not applicable
      (cannot infer type-variable(s) T#2
        (actual and formal argument lists differ in length))
  where T#1,T#2 are type-variables:
    T#1 extends Comparable<? super T#1> declared in method <T#1>sort(List<T#1>)
    T#2 extends Object declared in method <T#2>sort(List<T#2>,Comparator<? super T#2>)
Note: /home/martin/Documentos/programming/ontology/SNEPS/CSNePS-forked/CSNePS/src/jvm/edu/buffalo/cse/sneps3/gui/JungGraphPanel.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
Compilation of Java sources(lein javac) failed.

$ git checkout semtype-objectlang 
M   csneps.sh
M   csnepsgui.sh
Switched to branch 'semtype-objectlang'
Your branch is up-to-date with 'origin/semtype-objectlang'.

$ git branch
  master
* semtype-objectlang

$ ./csnepsgui.sh 
Compiling 4 source files to /home/(...)/SNEPS/CSNePS-forked/CSNePS/target/classes
Note: /home/(...)/SNEPS/CSNePS-forked/CSNePS/src/jvm/edu/buffalo/cse/sneps3/gui/JungGraphPanel.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Knowledge Base cleared. Contexts, slots, caseframes, and semantic types reinitialized.
ba7d5881-a55f-4a76-a5b3-d85646897506

BTW, after loading the demo in snepsgui, there's a null pointer exception, but the GUI seems to still work normally. I don't know if that's expected at this stage, otherwise I can open another issue if you like.

caseframe: MinMax
    type: :Proposition
    slots:  min3
        max3

class java.lang.Exception
class java.lang.Exception
Exception The set of fillers, #{b a}, is too few for the minimum restriction (3) on the slot min3.  csneps.util/error (util.clj:202)

class java.lang.Exception
class java.lang.Exception
Exception The set of fillers, #{4 3 1 2}, is too many for the maximum restriction (3) on the slot max3.  csneps.util/error (util.clj:202)

class java.lang.NullPointerException
class java.lang.NullPointerException
NullPointerException   edu.buffalo.cse.sneps3.gui.dataaccess.Model.getDownCableset (Model.java:346)

Cheers :)

jobez commented 2 years ago

is there any fix to this? i would love to be able to explore this project with cider x emacs but am getting the same java.lang.IllegalArgumentException: Key must be integer

edit: an easy enough workaround to those having difficulty of 'jacking-in' with cider is to run the lein repl :headless :host localhost and just run cider-connect