Problems using external libraries in a Protege plugin

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems using external libraries in a Protege plugin

M. Vreijling

Hello,

I'm trying to add a plugin that loads the current ontology and does a set of simple structural and syntax “house style” checks on the class structure and their names. However, trying to open the view of my new Protege 5.5 plugin Java crashes with a NoSuchMethodError:

Uncaught Exception in thread 'AWT-EventQueue-0'
java.lang.NoSuchMethodError: org.semanticweb.owlapi.model.OWLOntologyID.getOntologyIRI()Ljava/util/Optional;
       at nl.semlab.protege.plugin.view.AddTerm.<init>(AddTerm.java:114) ~[na:na] at nl.semlab.protege.plugin.view.AddTermViewComponent.initialiseOWLView(AddTermViewComponent.java:17) ~[na:na]

Apparently the OWLOntologyID.getOntologyIRI() is not available on the classpath.


But if I add this particular package to the import statements of the maven bundle plugin (org.semanticweb.owlapi.model.OWLOntologyID;version="[4.2,5)") the plugin won’t load due to an unresolved requirements of the added package.


Error starting file:/C:/Program Files/Protege 5.5/plugins/ nl.semlab.protege.plugin-0.1.2 - kopie.jar
org.osgi.framework.BundleException: Unable to resolve nl.semlab.protege.plugin [20](R 20.0): missing requirement [nl.semlab.protege.plugin [20](R 20.0)] osgi.wiring.package; (&(osgi.wiring.package=org.semanticweb.owlapi.model.OWLOntologyID)(version>=4.2.0)(!(version>=5.0.0))) Unresolved requirements: [[nl.semlab.protege.plugin [20](R 20.0)] osgi.wiring.package; (&(osgi.wiring.package=org.semanticweb.owlapi.model.OWLOntologyID)(version>=4.2.0)(!(version>=5.0.0)))]
       

Alternatively, if I remove the import statement but include the full distribution of org.semanticweb.owlapi (version 4.5.6) to my plugin jar, the plugin still crashes upon opening, but now  with a Loader constraint violation :

Uncaught Exception in thread 'AWT-EventQueue-0'

java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/ BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "org/semanticweb/owlapi/model/OWLOntology"

       at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_40]


Can anyone please help as this is beginning to take a bit more time that expected.



_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Problems using external libraries in a Protege plugin

kcason

In my experience this is usually caused by my code trying to call a method that is “newer” than the version of the OWL API I am trying to link against. In other words, that method does not exist in an older version of the API and I am trying to link to it.

 

Make sure you are linking against a version of the OWL API that contains that method. I have had to download the source code for various versions and confirm that method exists where I expect it. In most cases I end up changing the version of the API I link against.

 

Good luck!

 

-Kenny

 

From: protege-dev <[hidden email]> On Behalf Of Mark Vreijling
Sent: Monday, January 28, 2019 9:42 AM
To: Developer support for WebProtege and Protege Desktop <[hidden email]>
Subject: [protege-dev] Problems using external libraries in a Protege plugin

 

Hello,

I'm trying to add a plugin that loads the current ontology and does a set of simple structural and syntax “house style” checks on the class structure and their names. However, trying to open the view of my new Protege 5.5 plugin Java crashes with a NoSuchMethodError:

Uncaught Exception in thread 'AWT-EventQueue-0'
java.lang.NoSuchMethodError: org.semanticweb.owlapi.model.OWLOntologyID.getOntologyIRI()Ljava/util/Optional;
       at nl.semlab.protege.plugin.view.AddTerm.<init>(AddTerm.java:114) ~[na:na] at nl.semlab.protege.plugin.view.AddTermViewComponent.initialiseOWLView(AddTermViewComponent.java:17) ~[na:na]

Apparently the OWLOntologyID.getOntologyIRI() is not available on the classpath.

 

But if I add this particular package to the import statements of the maven bundle plugin (org.semanticweb.owlapi.model.OWLOntologyID;version="[4.2,5)") the plugin won’t load due to an unresolved requirements of the added package.


Error starting file:/C:/Program Files/Protege 5.5/plugins/ nl.semlab.protege.plugin-0.1.2 - kopie.jar
org.osgi.framework.BundleException: Unable to resolve nl.semlab.protege.plugin [20](R 20.0): missing requirement [nl.semlab.protege.plugin [20](R 20.0)] osgi.wiring.package; (&(osgi.wiring.package=org.semanticweb.owlapi.model.OWLOntologyID)(version>=4.2.0)(!(version>=5.0.0))) Unresolved requirements: [[nl.semlab.protege.plugin [20](R 20.0)] osgi.wiring.package; (&(osgi.wiring.package=org.semanticweb.owlapi.model.OWLOntologyID)(version>=4.2.0)(!(version>=5.0.0)))]
       

Alternatively, if I remove the import statement but include the full distribution of org.semanticweb.owlapi (version 4.5.6) to my plugin jar, the plugin still crashes upon opening, but now  with a Loader constraint violation :

Uncaught Exception in thread 'AWT-EventQueue-0'

java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/ BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "org/semanticweb/owlapi/model/OWLOntology"

       at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_40]

 

Can anyone please help as this is beginning to take a bit more time that expected.

 


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev