Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8280721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:47:05+00:00 2026-06-08T09:47:05+00:00

I have a particular Class URI for which I am trying to get an

  • 0

I have a particular Class URI for which I am trying to get an OntClass. The model is a regular model.

I wrote some code to find out whether the right statements were in the model, and it seems that they are so I can’t understand why it won’t let me view this as an OntClass. (tblURI is a String passed as a method parameter)

Resource tblR = m.createResource(tblURI);
List<Statement> prp = tblR.listProperties().toList();
for(Statement s : prp)
    System.out.println(s);
System.out.println(tblR.canAs(OntClass.class));
OntClass tbl = tblR.as(OntClass.class);

This is the output:

[kps:datasource/EnsembleMS#translation_stable_id, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://www.w3.org/2002/07/owl#Class]
[kps:datasource/EnsembleMS#translation_stable_id, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://www.w3.org/2000/01/rdf-schema#Class]
[kps:datasource/EnsembleMS#translation_stable_id, http://www.w3.org/2000/01/rdf-schema#isDefinedBy, kps:datasource/EnsembleMS]
[kps:datasource/EnsembleMS#translation_stable_id, http://www.w3.org/2000/01/rdf-schema#label, "translation_stable_id"]
false
com.hp.hpl.jena.ontology.ConversionException: Cannot convert node kps:datasource/EnsembleMS#translation_stable_id to OntClass: it does not have rdf:type owl:Class or equivalent
    at com.hp.hpl.jena.ontology.impl.OntClassImpl$1.wrap(OntClassImpl.java:81)
    at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:155)
    at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:34)
    at com.hp.hpl.jena.enhanced.Polymorphic.asInternal(Polymorphic.java:66)
    at com.hp.hpl.jena.enhanced.EnhNode.as(EnhNode.java:110)
    at com.KPS.myApp.exampleMethod(myApp.java:123)

Why is it throwing an exception and how can I get an OntClass for the resource with uri tblURI?

Thanks for any pointers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:47:06+00:00Added an answer on June 8, 2026 at 9:47 am

    You don’t say what kind of model m is. In particular, if m was created with the RDFS language profile, the OntModel will be looking for an rdf:type of rdfs:Class, not owl:Class. If that’s not the issue, then a complete minimal (i.e. runnable) example would help.

    By the way, there’s another problem I can see: resource URI’s in the model should be in absolute form, not abbreviated form. The fact that you’ve got q-name URI’s in your model, like kps:datasource/EnsembleMS#translation_stable_id, suggest that something is going wrong with your prefix handling. That won’t by itself cause the problem you’ve reported, but it’s a red flag to investigate.

    Update

    Responding to questions:

    • yes, you need to be using an OntModel, otherwise it’s not possible for the OntClass to know which langauge profile to use. Either create the model as OntModel in the first place:

      OntModel m = modelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
      

      or wrap your plain model as an OntModel:

      OntModel om = modelFactory.createOntologyModel( OntModelSpec.OWM_MEM, m );
      

      Of course, you many use any of the model specifications, as you please, OWL_MEM is just one option.

    • createResource will not expand prefixes for you. So, you should expand them yourself before creating the resource:

      m.createResource( m.expandPrefix( "foo:bar" ) );
      

      Of course, this requires the prefix "foo" to be registered as a prefix. This happens automatically if you read an RDF document that defines the prefix in its syntax, but otherwise can be done manually with setNsPrefix.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load text of all divs that have a particular class into
I have an AlarmReceiver class which executes when alarm rings at a particular time
I have JavaScript method which acts when a particular class (mcb) of forms are
I have an object created which belongs to particular class. var schCom1 = Server.CreateObject(ArchiveProgID);
I have a particular class that stores a piece of data, which implements an
I have a class, the stub of which is shown below. Code analysis gripes
I have a list of spans with particular class place and some of them
I have some delphi code which I need to migrate / port / re-write
Assume that I have a particular class of object that defines a class method
I have List of particular class. I want to save this List at a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.