You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Prasad Jeewantha <je...@gmail.com> on 2012/10/08 14:33:50 UTC

Embedding dependencies to Bundle: Please help

Hi all,
I kindly need a little bit of help to add some dependencies to one of my
OSGi Bundles. I am developing a small project which has two maven modules
(module1 and module2). I have configured each pom file of the two modules
to be OSGi bundles (bundle1 and bundle2). Both the bundles have some
dependencies like
       <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
            <type>jar</type>
        </dependency>
       <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.12</version>
            <scope>compile</scope>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework.version}</version>
            <type>jar</type>
        </dependency>

What I want is to embed these dependencies in one of the Bundles(bundle2)
so that my system can run. These are the two pom files of the two maven
modules.

Pom file of module 1:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.directfn</groupId>
        <artifactId>makrinos</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>makrinos-cache</artifactId>
    <packaging>${packagingName}</packaging>
    <name>Makrinos Cache</name>
    <url>http://maven.apache.org</url>

    <profiles>

        <profile>
            <id>osgi</id>
            <activation>
                <property>
                    <name>osgi</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <version>2.3.5</version>
                        <extensions>true</extensions>
                        <configuration>
                            <instructions>

<Bundle-SymbolicName>makrinos-cache</Bundle-SymbolicName>
                                <Bundle-Name>makrinos-cache</Bundle-Name>
                                <Export-Package>
                                    com.directfn.mixcache,
                                    com.directfn.mixcache.admincenter,
                                    com.directfn.mixcache.cachecore,
                                    com.directfn.mixcache.cachehashmaps;
                                </Export-Package>
                                <Import-Package>
                                    org.apache.log4j.*;
                                </Import-Package>
                                <Private-Package>
                                </Private-Package>
                            </instructions>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
</profiles>
</project>

Pom file of module 2:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.directfn</groupId>
        <artifactId>makrinos</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>makrinos-core</artifactId>
    <packaging>${packagingName}</packaging>
    <name>Makrinos Core</name>

    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>com.directfn</groupId>
            <artifactId>makrinos-cache</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>${packagingName}</type>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
            <type>jar</type>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>osgi</id>
            <activation>
                <property>
                    <name>osgi</name>
                </property>
            </activation>
            <build>
                <plugins>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.3.5</version>
                    <extensions>true</extensions>

                    <configuration>
                        <instructions>

<Bundle-SymbolicName>makrinos-core</Bundle-SymbolicName>
                            <Bundle-Name>makrinos-core</Bundle-Name>
                            <Export-Package>
                                com.directfn.makrinos.*;
                            </Export-Package>
                            <Import-Package>
                                com.directfn.mixcache,
                                com.directfn.mixcache.admincenter,
                                com.directfn.mixcache.cachecore,
                                net.sf.json,
                                org.apache.log4j,
                                org.springframework.context,

org.springframework.context.support;resolution:=optional
                            </Import-Package>
                            <Private-Package>
                            </Private-Package>
                            <Embed-Dependency>
                                json-lib,
                                log4j,

spring-context;scope=compile|runtime;inline=false</Embed-Dependency>
                            <Embed-Transitive>true</Embed-Transitive>
                        </instructions>
                    </configuration>
                </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

compiling these modules give errors:

[INFO] --- maven-bundle-plugin:2.3.5:bundle (default-bundle) @
makrinos-core ---
[ERROR] Bundle com.directfn:makrinos-core:bundle:1.0-SNAPSHOT : Unresolved
references to [bsh, com.sun.jdmk.comm, com.sun.net.httpserver,
edu.emory.mathcs.backport.java.util.concurrent, groovy.lang,
javax.annotation, javax.ejb, javax.interceptor, javax.jms, javax.mail,
javax.mail.internet, javax.management, javax.management.modelmbean,
javax.management.openmbean, javax.management.remote, javax.naming,
javax.persistence.spi, javax.rmi, javax.swing, javax.swing.border,
javax.swing.event, javax.swing.table, javax.swing.text, javax.swing.tree,
javax.validation, javax.validation.bootstrap, javax.validation.metadata,
javax.validation.spi, javax.xml.namespace, javax.xml.parsers, javax.xml.ws,
junit.framework, net.sf.cglib.asm, net.sf.cglib.core, net.sf.cglib.proxy,
net.sf.ezmorph, net.sf.ezmorph.array, net.sf.ezmorph.bean,
net.sf.ezmorph.object, nu.xom, org.aopalliance.aop,
org.aopalliance.intercept, org.apache.commons.beanutils,
org.apache.commons.collections.map, org.apache.commons.lang,
org.apache.commons.lang.builder, org.apache.commons.lang.exception,
org.apache.commons.lang.math, org.apache.commons.logging,
org.apache.oro.text.regex, org.aspectj.weaver.loadtime,
org.codehaus.groovy.control, org.codehaus.groovy.reflection,
org.codehaus.groovy.runtime, org.codehaus.groovy.runtime.callsite,
org.codehaus.groovy.runtime.typehandling,
org.codehaus.groovy.runtime.wrappers,
org.hibernate.validator.messageinterpolation,
org.hibernate.validator.resourceloading, org.joda.time,
org.joda.time.format, org.jruby, org.jruby.ast, org.jruby.exceptions,
org.jruby.javasupport, org.jruby.runtime, org.jruby.runtime.builtin,
org.omg.CORBA, org.springframework.aop, org.springframework.aop.framework,
org.springframework.aop.framework.adapter,
org.springframework.aop.intercept............................................
............................................
............................................

Can anybody please help me to figure out how to fix this?
Thanks in advance,
Jeewantha

Re: Embedding dependencies to Bundle: Please help

Posted by Prasad Jeewantha <je...@gmail.com>.
Worked like a charm. Thanks you so much!!! :)

On Mon, Oct 8, 2012 at 8:26 PM, Chetan Mehrotra
<ch...@gmail.com>wrote:

> In your Import-Package instruction
>
> >                             <Import-Package>
> >                                 com.directfn.mixcache,
> >                                 com.directfn.mixcache.admincenter,
> >                                 com.directfn.mixcache.cachecore,
> >                                 net.sf.json,
> >                                 org.apache.log4j,
> >                                 org.springframework.context,
> >
> > org.springframework.context.support;resolution:=optional
> >                             </Import-Package>
>
> You have missed adding an asterik (*) in the end i.e.
> org.springframework.context.support;resolution:=optional,* due to
> which bnd was not able to add required import instruction. Try adding
> the * .
>
> Chetan Mehrotra
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Embedding dependencies to Bundle: Please help

Posted by Chetan Mehrotra <ch...@gmail.com>.
In your Import-Package instruction

>                             <Import-Package>
>                                 com.directfn.mixcache,
>                                 com.directfn.mixcache.admincenter,
>                                 com.directfn.mixcache.cachecore,
>                                 net.sf.json,
>                                 org.apache.log4j,
>                                 org.springframework.context,
>
> org.springframework.context.support;resolution:=optional
>                             </Import-Package>

You have missed adding an asterik (*) in the end i.e.
org.springframework.context.support;resolution:=optional,* due to
which bnd was not able to add required import instruction. Try adding
the * .

Chetan Mehrotra

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org