Maven dependecy org.apache.commons.math error

128 views
Skip to first unread message

zaras

unread,
Oct 15, 2012, 9:22:50 AM10/15/12
to cytoscap...@googlegroups.com
Hello,

I have a plugin for Cytoscape 3.0 with a dependency on the external library org.apache.commons.math (2.1)
Compilation is ok but at runtime the dependency jar is not getting deployed or bundled when starting Cytoscape 3.0:

org.osgi.framework.BundleException: Unresolved constraint in bundle org.cytoscape.dyn [48]:
Unable to resolve 48.0: missing requirement [48.0] package; (&(package=org.apache.commons.math)(version>=2.1.0)(!(version>=3.0.0)))

The dependency is specified as a Maven dependency in the pom file:

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-math</artifactId>
    <version>2.1</version>
</dependency>

How can I fix this?
Thanks in advance,

Sabina

Jason Montojo

unread,
Oct 15, 2012, 10:38:26 AM10/15/12
to cytoscap...@googlegroups.com
Hi Sabina,

You can bundle your dependencies in your app JAR by adding the following snippet to your pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>${maven-bundle-plugin.version}</version>
            <configuration>
                <instructions>
                    ...
                    <Embed-Dependency>commons-math;groupId=org.apache.commons;inline=true</Embed-Dependency>
                    <Import-Package>*;resolution:=optional</Import-Package>
                    ...
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

The other alternative is to use Bnd to wrap commons-math as an OSGi bundle and distribute that with your app bundle.  Unfortunately, the App Store doesn't currently support multi-bundle apps yet, so you wouldn't be able to distribute your app through that channel.  Embedding the dependency as described above is probably the best thing to do for now.

Hope this helps,
Jason


--
You received this message because you are subscribed to the Google Groups "cytoscape-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cytoscape-discuss/-/1U1dU1pPC0UJ.
To post to this group, send email to cytoscap...@googlegroups.com.
To unsubscribe from this group, send email to cytoscape-disc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cytoscape-discuss?hl=en.

zaras

unread,
Oct 16, 2012, 12:41:31 PM10/16/12
to cytoscap...@googlegroups.com
Thanks Jason, that works fine!
Reply all
Reply to author
Forward
0 new messages