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

SPARQL Tab Comes up Empty in 5.6 if You Have Ontology Open #1110

Open
mdebellis opened this issue Mar 6, 2023 · 25 comments
Open

SPARQL Tab Comes up Empty in 5.6 if You Have Ontology Open #1110

mdebellis opened this issue Mar 6, 2023 · 25 comments
Labels
Status: Reproduced For issues that are (critical) bugs, denotes that the bug is reproduced, but no further action taken Type: Bug Indicates that Protege is not working as expected

Comments

@mdebellis
Copy link

This is a low priority IMO because I almost never use the SPARQL Tab anyway, perhaps it should just be removed. But there was something I wanted to do that Snap SPARQL didn't support (coercing strings to decimals using: "xsd:decimal(?numstr)" ) that I wanted to try to see if the SPARQLTab might support. If you just open Protégé and do Windows>Tab>SPARQL Query you get the normal SPARQL query. But if you first open an ontology and then do Windows>Tab>SPARQL Query the SPARQL Tab is empty and you can't enter a query and there is a bug in the log:

Sparql Tab in 5-6

Beginning of bug trace from log: 
 INFO  10:17:25  Disposed of 'DL Query' tab
   INFO  10:17:25  Disposed of workspace
   INFO  10:17:25  
   INFO  10:17:26  [IdRanges] Updating entity creation preferences
  ERROR  10:17:44  Uncaught Exception in thread 'AWT-EventQueue-0'
java.lang.NoSuchMethodError: 'void org.semanticweb.owlapi.rdf.model.AbstractTranslator.<init>(org.semanticweb.owlapi.model.OWLOntologyManager, org.semanticweb.owlapi.model.OWLOntology, boolean, org.semanticweb.owlapi.util.IndividualAppearance, org.semanticweb.owlapi.util.AxiomAppearance, java.util.concurrent.atomic.AtomicInteger, java.util.Map)'
	at org.protege.owl.rdf.impl.RDFTranslator.<init>(RDFTranslator.java:107) ~[na:na]
	at org.protege.owl.rdf.impl.RDFTranslator.translate(RDFTranslator.java:55) ~[na:na]
	at org.protege.owl.rdf.impl.OwlTripleStoreImpl.addAxiom(OwlTripleStoreImpl.java:99) ~[na:na]
	at org.protege.owl.rdf.Utilities.loadOwlTripleStore(Utilities.java:48) ~[na:na]
	at org.protege.owl.rdf.Utilities.getOwlTripleStore(Utilities.java:32) ~[na:na]
	at org.protege.editor.owl.rdf.repository.Basic
SparqlReasoner.precalculate(BasicSparqlReasoner.java:54) ~[na:na]
	at org.protege.editor.owl.rdf.SparqlQueryView.initializeReasoner(SparqlQueryView.java:34) ~[na:na]
	at org.protege.editor.owl.rdf.SparqlQueryView.initialiseOWLView(SparqlQueryView.java:24) ~[na:na]
@gouttegd gouttegd added Type: Bug Indicates that Protege is not working as expected Status: Reproduced For issues that are (critical) bugs, denotes that the bug is reproduced, but no further action taken labels Mar 23, 2023
@LorenzBuehmann
Copy link

Happens because of OWL API version conflict, specific issue opened here: protegeproject/rdf-library#12

@LeleDallas
Copy link

Same issue on mac m1

@santos-sicilia
Copy link

Hi, I am suffering the same problem.
What is the solution? I have reached a repository with AbstractTranslator.java file but I unknow how to fix the problem.

Best Regards,
Leo

@mdebellis
Copy link
Author

mdebellis commented Aug 2, 2023 via email

@santos-sicilia
Copy link

Thanks Michael,

But I have tried a simple query with Snap SPARQL and I cannot understand why it does not work. The query is:

PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX bfiao: http://www.semanticweb.org/leopo/ontologies/2021/0/BFiaO_v1.24#

SELECT ?subclass where {
?subclass rdfs:subClassOf bfiao:node
}

Instead of listing all the subclasses of node, I get a syntax error in SPARQL query:
"Encountered bfiao:node at line 7 column 30. Expected one of:
Variable
Class name (prefix name)"

Do you have any idea of this syntax error? (thanks in advance)
Leo

@mdebellis
Copy link
Author

mdebellis commented Aug 2, 2023 via email

@santos-sicilia
Copy link

Thanks again Michael,

Your sentences work perfectly but I would like to be more restrictive and just obtain the subclasses of an specific class. It is quite curious that with a specific class of the ontology it does not work.
It is a pity that I cannot load an image to show you a part of the ontology with node as a class.

In any case, thanks for your time !!
Leo

@mdebellis
Copy link
Author

Leo, I'm replying here because I didn't want to take up the bandwidth of the whole list for this. First, have you done my revised Pizza tutorial? If you haven't I think it would be worthwhile although you might want to skip the parts on SWRL and SHACL but I have a section on SPARQL that is a good overview: https://www.michaeldebellis.com/post/new-protege-pizza-tutorial

Second, you can use the same pattern as I used to get the subclasses of owl:Thing to get the subclasses of any class. Just replace owl:Thing with dmn:MyClass where dmn is a correctly prefixed namespace for your ontology. Make sure you run the reasoner first and that should work in Snap SPARQL.

Third, you can take screenshots of your ontology and send them to me directly: [email protected] I use Snipping Tool on Windows and whatever OS you are on there must be something similar. It depends how much time I have but I often spend an hour or so a day helping random new users with basic OWL questions. You can also just send your ontology to me as long as it isn't too large. In the future when you submit things to the Protégé list it is best to include screen snapshots and the ontology as well (as long as the ontology is fairly small). That makes it much easier for me and others to debug things. It depends who has time, often no one has the time to debug ontologies but sometimes people like me and others can just take a quick look and spot basic issues very quickly so if the ontology is small (which is usually the case for new users) it is best to attach it when you submit a message to the list. Good luck, feel free to let me know if you need more help.

@santos-sicilia
Copy link

Thank you very much Michael,

I have followed your tutorial, and everything worked with the previous Protégé version. But I will follow your advise and try it again just to see if I have done some mistake with the PREFIX and the ontology.

I will send you some screenshots of the ontology to your email. I am sure that there is something simple behind but I cannot see it yet. I promise no to abuse your time, and of course I really appreciate it.

@yasenstar
Copy link

Thanks for the information and workaround.

The Issue is still there in Protege 5.6.2, hope it can be fixed soon in future version.

During learning Michael's tutorial, I've made one specific video on this issue through certain testing, for your reference: https://youtu.be/oz1JaawLmJQ

@trapperkeeper
Copy link

I just wanted to add a bit of information to this issue. Some have suggested using the Snap SPARQL plugin as an alternative. It is worth mentioning that the Snap SPARQL plugin does not support property path expressions (e.g does not support all of SPARQL 1.1).

@LorenzBuehmann
Copy link

As I mentioned in my first comment, this is an easy to fix issue, the Github issue is also there: protegeproject/rdf-library#12
But it looks like not being that important or nobody had time to invest.

As a workaround, I uploaded a fixed rdf-library JAR file at my fork: https://github.com/LorenzBuehmann/rdf-library/

Maybe @mdebellis can give it a try.

@gouttegd
Copy link
Collaborator

gouttegd commented Feb 7, 2024

this is an easy to fix issue

Maybe not, unfortunately – even if rdf-library is updated to use the same version of the OWL API as Protégé itself, it still causes Protégé to hang when attempting to use the SPARQL Query tab.

@LorenzBuehmann
Copy link

Can't reproduce this with Protege 5.6.3 and the rdf-library file I uploaded here

image

Did you replace the existing rdf-library.jar file?
What does the log say when it hangs?
Is there still the exception?

java.lang.NoSuchMethodError: 'void org.semanticweb.owlapi.rdf.model.AbstractTranslator.<init>(org.semanticweb.owlapi.model.OWLOntologyManager, org.semanticweb.owlapi.model.OWLOntology, boolean, org.semanticweb.owlapi.util.IndividualAppearance, org.semanticweb.owlapi.util.AxiomAppearance, java.util.concurrent.atomic.AtomicInteger, java.util.Map)'

@gouttegd
Copy link
Collaborator

gouttegd commented Feb 8, 2024

Yes, I replaced the existing rdf-library.jar file. I tried both with your build and my own build from the tip of RDF-Library’s master branch, both on macOS and GNU/Linux (Protégé 5.6.3 in both cases). Same result.

The library and the SPARQL plugins are loaded fine without errors, but Protégé hangs as soon as I try to get to the SPARQL Query tab. No exceptions, nothing at all in the log.

@vjborges
Copy link

Can't reproduce this with Protege 5.6.3 and the rdf-library file I uploaded here

image

Did you replace the existing rdf-library.jar file? What does the log say when it hangs? Is there still the exception?

java.lang.NoSuchMethodError: 'void org.semanticweb.owlapi.rdf.model.AbstractTranslator.<init>(org.semanticweb.owlapi.model.OWLOntologyManager, org.semanticweb.owlapi.model.OWLOntology, boolean, org.semanticweb.owlapi.util.IndividualAppearance, org.semanticweb.owlapi.util.AxiomAppearance, java.util.concurrent.atomic.AtomicInteger, java.util.Map)'

Thanks very much. It works for me.

@mdebellis
Copy link
Author

Just tried it and still get the same error. I didn't try loading any jar files or anything so perhaps that's the problem, I notice it seems to be calling an undefined method in rdf.model. I had an ontology open and when I tried to open the SPARQL tab I get the following error. Note: the error may have to do with the GUI because when I do Window>Tabs>SPARQL Query I don't see any error messages but then when I click on the new SPARQL tab, I see the error below and I can't enter anything into the SPARQL tab, it doesn't respond. I'm running on Windows 11 Pro.

ERROR 17:25:26 Uncaught Exception in thread 'AWT-EventQueue-0'
java.lang.NoSuchMethodError: 'void org.semanticweb.owlapi.rdf.model.AbstractTranslator.(org.semanticweb.owlapi.model.OWLOntologyManager, org.semanticweb.owlapi.model.OWLOntology, boolean, org.semanticweb.owlapi.util.IndividualAppearance, org.semanticweb.owlapi.util.AxiomAppearance, java.util.concurrent.atomic.AtomicInteger, java.util.Map)'
at org.protege.owl.rdf.impl.RDFTranslator.(RDFTranslator.java:107) ~[na:na]
at org.protege.owl.rdf.impl.RDFTranslator.translate(RDFTranslator.java:55) ~[na:na]
at org.protege.owl.rdf.impl.OwlTripleStoreImpl.addAxiom(OwlTripleStoreImpl.java:99) ~[na:na]
at org.protege.owl.rdf.Utilities.loadOwlTripleStore(Utilities.java:48) ~[na:na]
at org.protege.owl.rdf.Utilities.getOwlTripleStore(Utilities.java:32) ~[na:na]
at org.protege.editor.owl.rdf.repository.BasicSparqlReasoner.precalculate(BasicSparqlReasoner.java:54) ~[na:na]
at org.protege.editor.owl.rdf.SparqlQueryView.initializeReasoner(SparqlQueryView.java:34) ~[na:na]
at org.protege.editor.owl.rdf.SparqlQueryView.initialiseOWLView(SparqlQueryView.java:24) ~[na:na]
at org.protege.editor.owl.ui.view.AbstractOWLViewComponent.initialise(AbstractOWLViewComponent.java:43) ~[na:na]
at org.protege.editor.core.ui.view.View.createContent(View.java:413) ~[na:na]
at org.protege.editor.core.ui.view.View.createUI(View.java:220) ~[na:na]
at org.protege.editor.core.ui.view.View$1.hierarchyChanged(View.java:124) ~[na:na]
at java.desktop/java.awt.Component.processHierarchyEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.processEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.processEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.createHierarchyEvents(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.createHierarchyEvents(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.createHierarchyEvents(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.createHierarchyEvents(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.createHierarchyEvents(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.createHierarchyEvents(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.show(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.show(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.setVisible(Unknown Source) ~[na:na]
at java.desktop/javax.swing.JComponent.setVisible(Unknown Source) ~[na:na]
at java.desktop/javax.swing.JTabbedPane.fireStateChanged(Unknown Source) ~[na:na]
at java.desktop/javax.swing.JTabbedPane$ModelListener.stateChanged(Unknown Source) ~[na:na]
at java.desktop/javax.swing.DefaultSingleSelectionModel.fireStateChanged(Unknown Source) ~[na:na]
at java.desktop/javax.swing.DefaultSingleSelectionModel.setSelectedIndex(Unknown Source) ~[na:na]
at java.desktop/javax.swing.JTabbedPane.setSelectedIndexImpl(Unknown Source) ~[na:na]
at java.desktop/javax.swing.JTabbedPane.setSelectedIndex(Unknown Source) ~[na:na]
at java.desktop/javax.swing.plaf.basic.BasicTabbedPaneUI$Handler.mousePressed(Unknown Source) ~[na:na]
at java.desktop/java.awt.AWTEventMulticaster.mousePressed(Unknown Source) ~[na:na]
at java.desktop/java.awt.AWTEventMulticaster.mousePressed(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source) ~[na:na]
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.processEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.processEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source) ~[na:na]
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source) ~[na:na]
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventQueue$4.run(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventQueue$4.run(Unknown Source) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) ~[na:na]
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventQueue$5.run(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventQueue$5.run(Unknown Source) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) ~[na:na]
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) ~[na:na]

@vjborges
Copy link

I used the jar available here - https://github.com/LorenzBuehmann/rdf-library/releases/tag/rdf-library-3.0.0

@yasenstar
Copy link

yasenstar commented Apr 4, 2024

Using the jar file mentioned by @vjborges, which I just place it in my Protege 5.6.3's plugins folder, leave the old rdf-library-3.0.0.jar still there, and the SPARQL query tab is now working fine.
Thanks @vjborges

@LorenzBuehmann
Copy link

That won't work keeping the old JAR still in use.

According to the README,

remove rdf-library-3.0.0.jar from $PROTEGE_HOME/plugins

@knbknb
Copy link

knbknb commented Apr 11, 2024

@gouttegd After replacing the Protege-5.6.2/plugins/rdf-library-3.0.0.jar file with Lorenz' patched version, and after placing the SPARQL query view on the SPARQL query tab, I saw a "ghost frame" (a transparent rectangle with grey border) where the view was about to be placed, and the Protege app was in a nonresponsive state for a while.

However I had to wait 3 minutes for the blank rectangle to disappear. Finally the SPARQL query tab showed up and was usable again even when an ontology was loaded. I have tried only 1 simple SPARQL queries though.

So I had to wait really long time, no idea what protege was doing.

@LorenzBuehmann
Copy link

Protege works with OWL API as Java library to load and process OWL ontologies. SPARQL on the other hand is based on RDF, and as Java library rdf4j or better said its predecessor Sesame is being used. So Protege has to convert from OWL API to Sesame API - this happens once you open the SPARQL query tab or to be more precise its wrapped SPARQL query view.

Each OWL axiom a is converted to a set of RDF triples T_a, then those triples are added to an in-memory triple store. To keep track of the correspondence between axiom and triples, i.e. as a kind of provenance, ''T_a'' is loaded into a separate named graph g_a.

Depending on the size of the data it may take some time, but I can't judge if a 3 minute waiting time is realistic.
What is the size of your ontology?

@knbknb
Copy link

knbknb commented Apr 11, 2024

I've used the relatively big, recent DBPedia Ontology -
After the initial import , reopening Protege with that big ontology works much faster, almost instantly. The point is, The nonresponsive "hanging state" happened only once.

In any event, thanks for your great patched jar file. Respect! It really blows my my how you have figured that out. It requires so much background knowledge.

@tejaswinihbhat
Copy link

PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX onto: http://www.example.org/ontologies/fish.owl#
SELECT ?species ?speciesName
WHERE {
?species rdfs:label ?speciesName.
FILTER NOT EXISTS { ?species onto:hasStatus ?Status. }
}
Capture
Can anyone help with this please

@LorenzBuehmann
Copy link

None of the Protege SPARQL views does support full SPARQL 1.1, thus, a query with FILTER (NOT)) EXISTS { ... } will fail. Mostly because the standard SPARQL view does work on an older Sesame backend and Snap SPARQL because of some custom SPARQL parser.
You could load your data into some triple store, among others, Apache Jena Fuseki, RDF4J, Virtuoso, all with support of full SPARQL 1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reproduced For issues that are (critical) bugs, denotes that the bug is reproduced, but no further action taken Type: Bug Indicates that Protege is not working as expected
Projects
None yet
Development

No branches or pull requests

10 participants