Error with openjdk java.lang.NoClassDefFoundError: javafx/util/Pair


#1

Hi,

I am currently experimenting with inference and constructed a small test to use transitive sub locations.
After entering the inference rule i started the graql shell with the “-n” option and entered a query which should use the inference rule.

I got the following error which seems to indicate that I need the javafx rt in the classpath. If this is correct is there a configuration I can use to work without javafx?

java.lang.NoClassDefFoundError: javafx/util/Pair
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.lambda$computeRoleVarTypeMap$23(Relation.java:529)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation$$Lambda$885.000000004C0ADFF0.accept(Unknown Source)
at java.lang.Iterable.forEach(Iterable.java:86)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.computeRoleVarTypeMap(Relation.java:524)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.getRoleVarTypeMap(Relation.java:602)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.hasMetaRoles(Relation.java:314)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.isAllowedToFormRuleHead(Relation.java:238)
at ai.grakn.graql.internal.reasoner.rule.InferenceRule.(InferenceRule.java:75)
at ai.grakn.graql.internal.reasoner.atom.Atom.lambda$getApplicableRules$3(Atom.java:135)
at ai.grakn.graql.internal.reasoner.atom.Atom$$Lambda$872.000000004C0AB320.apply(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:204)
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1559)
[…]

Best Regards


#2

Hi @fab,

At this stage our reasoner depends on javafx.Pair quite heavily so there is no option to run without it. We have not tried to support openjdk yet actually. For the moment you may have to switch to oracle jdk. Sorry about that.

Regards,

Filipe


#3

I’ve updated our README and docs to reflect this.


#4

Many thanks for your quick response!


#5

It looks like I am still doing something wrong, I have two inference rules which work but combining them results in the following error which does not look like a parse error in the query to me.

I have a workaround and I am not sure if this was cause by an earlier error so this is just for you to check in case you are interested.

java.lang.ClassCastException: ai.grakn.graph.internal.RoleTypeImpl cannot be cast to ai.grakn.concept.RelationType
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.computeRoleVarTypeMap(Relation.java:517)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.getRoleVarTypeMap(Relation.java:602)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.getRoleMap(Relation.java:278)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.getRoleConceptIdMap(Relation.java:266)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.equivalenceHashCode(Relation.java:209)
at ai.grakn.graql.internal.reasoner.query.ReasonerQueryImpl.lambda$hashCode$1(ReasonerQueryImpl.java:132)
at java.lang.Iterable.forEach(Iterable.java:75)
at ai.grakn.graql.internal.reasoner.query.ReasonerQueryImpl.hashCode(ReasonerQueryImpl.java:132)
at ai.grakn.graql.internal.reasoner.rule.InferenceRule.hashCode(InferenceRule.java:102)
at java.util.HashMap.hash(HashMap.java:338)
at java.util.HashMap.put(HashMap.java:611)
at java.util.HashSet.add(HashSet.java:219)
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1548)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at ai.grakn.graql.internal.reasoner.atom.Atom.getApplicableRules(Atom.java:137)
at ai.grakn.graql.internal.reasoner.query.ReasonerQueryImpl.requiresMaterialisation(ReasonerQueryImpl.java:481)
at ai.grakn.graql.internal.reasoner.query.ReasonerQueryImpl.resolve(ReasonerQueryImpl.java:557)
at ai.grakn.graql.internal.query.match.MatchQueryInfer.stream(MatchQueryInfer.java:59)
at ai.grakn.graql.internal.query.match.MatchQueryGraph.stream(MatchQueryGraph.java:48)
at ai.grakn.graql.internal.query.match.AbstractMatchQuery.stream(AbstractMatchQuery.java:86)
at ai.grakn.graql.internal.query.match.AbstractMatchQuery.resultsString(AbstractMatchQuery.java:59)
at ai.grakn.engine.session.GraqlSession.lambda$null$3(GraqlSession.java:224)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at ai.grakn.engine.session.GraqlSession.lambda$executeQuery$4(GraqlSession.java:224)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)


#6

Hmmm that might be a bug on our side. Can you paste your ontology + the rules which produce this issue? Or a minimal example which produces the problem if you don’t want to share your ontology? It might be an incorrect resolution leading to an incorrect casting or it might be an error in the rule itself.


#7

OK, it took some time and I did not check if this is really a minimal example but it reproduces the error with grakn 13.0 on a linux machine:

The (toy) ontology I have used is:

insert
name sub resource datatype string;

contains_location sub role;
located_in sub role;
has_location sub role;
location_for sub role;
uses sub role;
used sub role;

location sub entity
has name
plays contains_location
plays located_in
plays location_for
;

sub_location sub relation
relates contains_location
relates located_in
;

using sub relation
relates uses
relates used
;

with_location sub relation
relates has_location
relates location_for
;

event sub entity
plays has_location
plays uses
has name
;

building sub entity
has name
plays used
plays has_location
;

$1 isa location has name “middle earth”;
$2 isa location has name “shire”;
$3 (contains_location: $1, located_in: $2) isa sub_location;
$4 isa building has name “bag end”;
$7 (has_location: $4, location_for: $2) isa with_location;
$5 isa event has name “bilbos 111th birthday party”;
$6 (uses: $5, used: $4) isa using;

$transitive_sub_location isa inference-rule
lhs {
$l1 isa location;
$l2 isa location;
$l3 isa location;
(contains_location: $l1, located_in: $l2) isa sub_location;
(contains_location: $l2, located_in: $l3) isa sub_location;
}
rhs {
(contains_location: $l1, located_in: $l3) isa sub_location;
}
;

$even_location isa inference-rule
lhs {
$e isa event;
$b isa building;
$l isa location;
(has_location: $b, location_for: $l) isa with_location;
(uses: $ft, used:$f) isa uses;
}
rhs {
(has_location: $ft, location_for: $l) isa with_location;
}
;

Using graql.sh with the -n option and -k for the keyspace I used and the following query

match $e isa event; $l isa location has name “middle earth”; (has_location:$e, location_for:$l);

produces

java.lang.ClassCastException: ai.grakn.graph.internal.RoleTypeImpl cannot be cast to ai.grakn.concept.RelationType
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.computeRoleVarTypeMap(Relation.java:517)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.getRoleVarTypeMap(Relation.java:602)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.getRoleMap(Relation.java:278)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.getRoleConceptIdMap(Relation.java:266)
at ai.grakn.graql.internal.reasoner.atom.binary.Relation.equivalenceHashCode(Relation.java:209)
at ai.grakn.graql.internal.reasoner.query.ReasonerQueryImpl.lambda$hashCode$1(ReasonerQueryImpl.java:132)
at java.lang.Iterable.forEach(Iterable.java:75)

Hope this is usable


#8

Hello,
The problem is that you have used a role type uses as a relation type in the event_location rule:

(uses: $ft, used:$f) isa uses;

Hope that helps. Let us know if you have any other questions.


#9

Yes, this worked! Thanks for your help.

(The example I gave reproduced the error but did not make sense, just for the records here the corrected completed version)

insert
name sub resource datatype string;

contains_location sub role;
located_in sub role;
has_location sub role;
location_for sub role;
uses sub role;
used sub role;

location sub entity
has name
plays contains_location
plays located_in
plays location_for
;

sub_location sub relation
relates contains_location
relates located_in
;

using sub relation
relates uses
relates used
;

with_location sub relation
relates has_location
relates location_for
;

event sub entity
plays has_location
plays uses
has name
;

building sub entity
has name
plays used
plays has_location
;

$1 isa location has name “middle earth”;
$2 isa location has name “shire”;
$8 isa location has name “underhill”;
$3 (contains_location: $1, located_in: $2) isa sub_location;
$9 (contains_location: $2, located_in: $8) isa sub_location;
$4 isa building has name “bag end”;
$7 (has_location: $4, location_for: $8) isa with_location;
$5 isa event has name “bilbos 111th birthday party”;
$6 (uses: $5, used: $4) isa using;

$transitive_sub_location isa inference-rule
lhs {
$l1 isa location;
$l2 isa location;
$l3 isa location;
(contains_location: $l1, located_in: $l2) isa sub_location;
(contains_location: $l2, located_in: $l3) isa sub_location;
}
rhs {
(contains_location: $l1, located_in: $l3) isa sub_location;
}
;

$event_location isa inference-rule
lhs {
$e isa event;
$b isa building;
$l isa location;
(has_location: $b, location_for: $l) isa with_location;
(uses: $e, used:$b) isa using;
}
rhs {
(has_location: $e, location_for: $l) isa with_location;
}
;

The query

match $e isa event; $me isa location has name “middle earth”; $l isa location; (contains_location:$me, located_in:$l) ; (has_location:$e, location_for:$l);

correctly returns the event.

I could have found out reading the stack trace but maybe this type of input error could be reported in an error message?