Problems importing external libraries in plugin

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

Problems importing external libraries in plugin

M. Vreijling
Hi,
Can anybody direct me to the correct way of getting Protege to accept an
external library required by my plugin.
I have successfully build a simple Protege 5.5 plugin using eclipse. However
when I try to add more complex functions, the plugin no longer loads into
protege “Plugin was not successfully started” . Unfortunately no further
details are written to the Protege log.
I have narrowed the problem down to one of my .java files which states an
import from an external jar. Naturally, everything works fine within
eclipse.
Any help is much appreciated.




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Problems importing external libraries in plugin

Lorenz Buehmann
Protege plugins are plugged in via Osgi, so assuming that you're using Maven you have to configure the maven-bundle-plugin appropriately.

Hi,
Can anybody direct me to the correct way of getting Protege to accept an
external library required by my plugin.
I have successfully build a simple Protege 5.5 plugin using eclipse. However
when I try to add more complex functions, the plugin no longer loads into
protege “Plugin was not successfully started” . Unfortunately no further
details are written to the Protege log.
I have narrowed the problem down to one of my .java files which states an
import from an external jar. Naturally, everything works fine within
eclipse.
Any help is much appreciated.




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev


-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

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

Re: Problems importing external libraries in plugin

M. Vreijling
Thanks for your quick reaction. See below my current Maven pom. The troublesome imports are all from the htmlunit dependency. How should I configure this to be able to use them from within the classes in my jar?

  <modelVersion>4.0.0</modelVersion>
  <groupId>nl.semlab.protege.plugin</groupId>
  <artifactId>nl.semlab.protege.plugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 <name>Semlab Protege Plugin</name>
<description>Semlab plug-ins for the Protege Desktop ontology editor.</description>
<packaging>bundle</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>edu.stanford.protege</groupId>
<artifactId>protege-editor-owl</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.19</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<!-- Use resource filtering to replace references to the artifactId in 
the plugin.xml file -->
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>org.protege.editor.owl.ProtegeOWL</Bundle-Activator>
<Bundle-ClassPath>.</Bundle-ClassPath>
<Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
<Bundle-Vendor>The Protege Development Team</Bundle-Vendor>
<Import-Package>
org.protege.editor.owl.ui,
*
</Import-Package>
</instructions>
</configuration>
</plugin>

<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<pde>true</pde>
</configuration>
</plugin>
</plugins>
</build>
</project>





On Tue, 22 Jan 2019 at 16:13, Lorenz B. <[hidden email]> wrote:
Protege plugins are plugged in via Osgi, so assuming that you're using Maven you have to configure the maven-bundle-plugin appropriately.

Hi,
Can anybody direct me to the correct way of getting Protege to accept an
external library required by my plugin.
I have successfully build a simple Protege 5.5 plugin using eclipse. However
when I try to add more complex functions, the plugin no longer loads into
protege “Plugin was not successfully started” . Unfortunately no further
details are written to the Protege log.
I have narrowed the problem down to one of my .java files which states an
import from an external jar. Naturally, everything works fine within
eclipse.
Any help is much appreciated.




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev


-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev

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

Re: Problems importing external libraries in plugin

M. Vreijling
In reply to this post by Lorenz Buehmann
Hi Lorenz,
Thanks for the pointer. Apparently the way to go is to embed the required
jar using the <Embed-Dependency> instruction in the maven-bundle-plugin.
This leads to my next problem. The embedded dependency introduces a lot of
additional Import-package statement in the MANIFEST.MF of the protege plugin
jar. These subsequently cause org.osgi.framework.BundleExceptions , “missing
requirement” and  “Unresolved requirements”.
Could you point me in the right direction to resolve this.





--
Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Problems importing external libraries in plugin

Matthew Horridge-2
Administrator
Hi Mark,

You may need to embed more than one dependency in order to make the packages available.  If you know for sure that the packages are not required then you can exclude them in the configuration.  You can prefix packages with ‘!' in order to do this.

Cheers,

Matthew




> On Jan 23, 2019, at 04:42, M. Vreijling <[hidden email]> wrote:
>
> Hi Lorenz,
> Thanks for the pointer. Apparently the way to go is to embed the required
> jar using the <Embed-Dependency> instruction in the maven-bundle-plugin.
> This leads to my next problem. The embedded dependency introduces a lot of
> additional Import-package statement in the MANIFEST.MF of the protege plugin
> jar. These subsequently cause org.osgi.framework.BundleExceptions , “missing
> requirement” and  “Unresolved requirements”.
> Could you point me in the right direction to resolve this.
>
>
>
>
>
> --
> Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev

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

Re: Problems importing external libraries in plugin

M. Vreijling
Hello Matthew,

Thanks for you time. I wasn't able to get my jar working using the maven bundle plugin. Embedding my direct dependency even with <Embed-Transitive> true, did not result in the required packages.
Using <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency> resulted in so many unresolvable imports that it wasn't helpful either.
The only way to get my jar working was by hand-adding the subject of every subsequent ClassDefNotFoundException either by embedding the package or stating it as an import. Surely there must be an easier way?

Regards,

Mark

On Wed, 23 Jan 2019 at 18:49, Matthew Horridge <[hidden email]> wrote:
Hi Mark,

You may need to embed more than one dependency in order to make the packages available.  If you know for sure that the packages are not required then you can exclude them in the configuration.  You can prefix packages with ‘!' in order to do this.

Cheers,

Matthew




> On Jan 23, 2019, at 04:42, M. Vreijling <[hidden email]> wrote:
>
> Hi Lorenz,
> Thanks for the pointer. Apparently the way to go is to embed the required
> jar using the <Embed-Dependency> instruction in the maven-bundle-plugin.
> This leads to my next problem. The embedded dependency introduces a lot of
> additional Import-package statement in the MANIFEST.MF of the protege plugin
> jar. These subsequently cause org.osgi.framework.BundleExceptions , “missing
> requirement” and  “Unresolved requirements”.
> Could you point me in the right direction to resolve this.
>
>
>
>
>
> --
> Sent from: http://protege-project.136.n4.nabble.com/Protege-Developer-f4659816.html
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev

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

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