# ClassCastException impl.SimpleIRI to Literal on owl n10s.onto.import.fetch

**URL:** <https://community.neo4j.com/t/classcastexception-impl-simpleiri-to-literal-on-owl-n10s-onto-import-fetch/62421>\
**Category:** Linked Data, RDF, Ontology\
**Tags:** import\
**Created:** [May 8, 2023, 9:48pm UTC](https://community.neo4j.com/t/classcastexception-impl-simpleiri-to-literal-on-owl-n10s-onto-import-fetch/62421 "2023-05-08T21:48:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwong](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jwong/32/22254_2.png) [@jwong](https://community.neo4j.com/u/jwong)\
**Post date:** [May 8, 2023, 9:48pm UTC](https://community.neo4j.com/t/classcastexception-impl-simpleiri-to-literal-on-owl-n10s-onto-import-fetch/62421/1 "2023-05-08T21:48:28Z")

</div>

Hi,

I'm getting a ClassCastException when importing the Foodon ontology owl file. An earlier version of the ontology owl file works, but newer revisions fail with the following error:

> Failed to invoke procedure `n10s.onto.import.fetch`: Caused by: java.lang.ClassCastException: class org.eclipse.rdf4j.model.impl.SimpleIRI cannot be cast to class org.eclipse.rdf4j.model.Literal (org.eclipse.rdf4j.model.impl.SimpleIRI and org.eclipse.rdf4j.model.Literal are in unnamed module of loader 'app')

Here's the command I'm running that fails:

```auto
CALL n10s.onto.import.fetch("https://github.com/FoodOntology/foodon/raw/master/foodon.owl", "RDF/XML", {commitSize: 10000, nodeCacheSize: 20000});

```

Using a [specific revision of the file](https://github.com/FoodOntology/foodon/raw/3d6130586c0c795cd768823e9c2f43928b4fca62/foodon.owl) works:

```auto
CALL n10s.onto.import.fetch("https://github.com/FoodOntology/foodon/raw/3d6130586c0c795cd768823e9c2f43928b4fca62/foodon.owl", "RDF/XML", {commitSize: 10000, nodeCacheSize: 20000});

```

But the revision just after fails:

```auto
CALL n10s.onto.import.fetch("https://github.com/FoodOntology/foodon/raw/28bc881f27a24687269b5ad75eb99217f5c6c464/foodon.owl", "RDF/XML", {commitSize: 10000, nodeCacheSize: 20000});

```

Is there a problem with the Owl file that I should raise with the FoodOntology group or can this be fixed within neo4j?

Thanks!

---

<div class="post-metadata">

**Author:** ![jwong](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jwong/32/22254_2.png) [@jwong](https://community.neo4j.com/u/jwong)\
**Post date:** [May 31, 2023, 6:24pm UTC](https://community.neo4j.com/t/classcastexception-impl-simpleiri-to-literal-on-owl-n10s-onto-import-fetch/62421/2 "2023-05-31T18:24:36Z")

</div>

I believe I've found the offending change. Revision 28bc881f27a24687269b5ad75eb99217f5c6c464 adds `<rdfs:comment rdf:resource="&obo;IAO_0000122"/>` at line 13025. When I comment this out, the import works fine. With it in, the import fails.

I can also import the current revision by commenting out all `rdfs:comment` tags that use the `rdf:resource` attribute.

Is the `rdf:resource` attribute not allowed on the `rdfs:comment` tag? Or is this a bug with neosemantics?

---

<div class="post-metadata">

**Author:** ![jesus\_barrasa](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jesus_barrasa/32/27513_2.png) [@jesus\_barrasa](https://community.neo4j.com/u/jesus_barrasa)\
**Post date:** [June 2, 2023, 12:02am UTC](https://community.neo4j.com/t/classcastexception-impl-simpleiri-to-literal-on-owl-n10s-onto-import-fetch/62421/3 "2023-06-02T00:02:28Z")

</div>

Hi @jwong,

Nice catch!

[The RDFSchema spec](https://www.w3.org/TR/rdf12-schema/#ch_comment) says that the range of the `rdfs:comment` predicate is meant to be a literal.

This means that in RDF/XML serialisation the usage of the `rdfs:comment` tag should be like in the rest of the cases:  
`<rdfs:comment xml:lang="en">...some text...</rdfs:comment>`  
and not use the `rdf:resource` attribute.

Which leads me to think that this is a malformed RDF document.

That said, it would be relatively easy to have neosemantics deal with it and transform the uri in `rdf:resource` into a literal value. My concern is whether doing it would make neosemantics silently accept an error that should be flagged.  
Let me think about it but I would suggest reporting it to the editors of the food onto.

Cheers,

JB.

---

<div class="post-metadata">

**Author:** ![jwong](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jwong/32/22254_2.png) [@jwong](https://community.neo4j.com/u/jwong)\
**Post date:** [June 2, 2023, 4:32pm UTC](https://community.neo4j.com/t/classcastexception-impl-simpleiri-to-literal-on-owl-n10s-onto-import-fetch/62421/4 "2023-06-02T16:32:32Z")

</div>

Hi @jesus_barrasa!

We've been in contact with the Foodon ontology and confirmed that it is a mistake on their part, and they'll work on fixing it.

Thanks,  
Jeffrey
