You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "Roll, Kevin" <Ke...@idexx.com> on 2015/05/19 22:49:27 UTC

OSGi bundles and dependencies

Our project uses the Apache Sling framework, which is built on top of the Felix container. We have been given a jar file by another team which uses Apache CXF to connect to a web service. This is a list of the dependencies in that jar:

                <dependencies>
                                <dependency>
                                                <groupId>junit</groupId>
                                                <artifactId>junit</artifactId>
                                                <version>4.0</version>
                                                <scope>test</scope>
                                </dependency>
                                <dependency>
                                                <groupId>org.apache.cxf</groupId>
                                                <artifactId>cxf-api</artifactId>
                                                <version>2.7.2</version>
                                </dependency>
                                <dependency>
                                                <groupId>org.apache.httpcomponents</groupId>
                                                <artifactId>httpclient</artifactId>
                                                <version>4.1</version>
                                </dependency>
                                <dependency>
                                                <groupId>org.apache.httpcomponents</groupId>
                                                <artifactId>httpcore</artifactId>
                                                <version>4.2.3</version>
                                </dependency>
                                <dependency>
                                                <groupId>com.jgoodies</groupId>
                                                <artifactId>forms</artifactId>
                                                <version>1.1.0</version>
                                </dependency>
                                <dependency>
                                                <groupId>org.apache.cxf</groupId>
                                                <artifactId>cxf-rt-frontend-jaxws</artifactId>
                                                <version>2.7.2</version>
                                </dependency>
                                <dependency>
                                                <groupId>commons-io</groupId>
                                                <artifactId>commons-io</artifactId>
                                                <version>2.4</version>
                                </dependency>
                                <dependency>
                                                <groupId>commons-lang</groupId>
                                                <artifactId>commons-lang</artifactId>
                                                <version>2.6</version>
                                </dependency>
                                <dependency>
                                                <groupId>javax.activation</groupId>
                                                <artifactId>activation</artifactId>
                                                <version>1.1-rev-1</version>
                                </dependency>
                                 <dependency>
              <groupId>com.twmacinta</groupId>
              <artifactId>fast-md5</artifactId>
              <version>2.7.1</version>
  </dependency>
</dependencies>

I set up a module to generate an OSGi bundle from this library. Here is my configuration:

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.5.4</version>
                <extensions>true</extensions>
                <configuration>
                    <obrRepository>NONE</obrRepository>
                    <manifestLocation>META-INF</manifestLocation>
                    <instructions>
                        <Export-Package>com.idexx.imaging*</Export-Package>
                        <Import-Package>

                            !com.sun*;!junit*;!jgoodies*;!net.sf*;!org.apache.aries*;!org.apache.avalon*;
                            !org.apache.axiom*;!org.apache.cxf.tools.common*;!org.apache.cxf.tools.validator*;
                            !org.apache.geronimo*;!org.apache.log*;!org.apache.mina*;!org.junit*;!org.jvnet*;
                            !org.osgi.service*;!org.relaxng*;!org.springframework*;
                            *
                        </Import-Package>
                        <Embed-Dependency>
                            !org.apache.felix*;*;scope=compile|runtime
                        </Embed-Dependency>
                        <Embed-Transitive>true</Embed-Transitive>
                        <Bundle-ClassPath>{maven-dependencies},.</Bundle-ClassPath>
                    </instructions>
                </configuration>
                <executions>
                                ...
            </plugin>

My question is about that long list of Import-Package exclusions. When I initially ran my OSGi bundle in Felix it complained about missing dependencies. I arrived at this list by iteratively excluding things until I came to a configuration that worked. Why are there so many things I need to exclude? Shouldn't these dependencies be picked up by the Embed-Transitive flag? They can't really all be dynamic dependencies, can they? Could an incorrect POM file provided by the other team be part of this? Any insight is greatly appreciated. Thanks!


Re: OSGi bundles and dependencies

Posted by Frank Langel <fr...@frankjlangel.com>.
Kevin,

You are trying to merge all jar files into a larger jar. This is possible,
but its not necessarily best practice. If you want to run these packages
on felix, setup felix and add these bundles to felix. I can recommend this
page

	http://felix.apache.org/documentation/subprojects/apache-felix-framework.h
tml


Plus check out bndtools and the tutorials @amdatu.org

Frank


On 5/19/15, 10:49 PM, "Roll, Kevin" <Ke...@idexx.com> wrote:

>Our project uses the Apache Sling framework, which is built on top of the
>Felix container. We have been given a jar file by another team which uses
>Apache CXF to connect to a web service. This is a list of the
>dependencies in that jar:
>
>                <dependencies>
>                                <dependency>
>                                                <groupId>junit</groupId>
>                  
><artifactId>junit</artifactId>
>                                                <version>4.0</version>
>                                                <scope>test</scope>
>                                </dependency>
>                                <dependency>
>                  
><groupId>org.apache.cxf</groupId>
>                  
><artifactId>cxf-api</artifactId>
>                                                <version>2.7.2</version>
>                                </dependency>
>                                <dependency>
>                  
><groupId>org.apache.httpcomponents</groupId>
>                  
><artifactId>httpclient</artifactId>
>                                                <version>4.1</version>
>                                </dependency>
>                                <dependency>
>                  
><groupId>org.apache.httpcomponents</groupId>
>                  
><artifactId>httpcore</artifactId>
>                                                <version>4.2.3</version>
>                                </dependency>
>                                <dependency>
>                  
><groupId>com.jgoodies</groupId>
>                  
><artifactId>forms</artifactId>
>                                                <version>1.1.0</version>
>                                </dependency>
>                                <dependency>
>                  
><groupId>org.apache.cxf</groupId>
>                  
><artifactId>cxf-rt-frontend-jaxws</artifactId>
>                                                <version>2.7.2</version>
>                                </dependency>
>                                <dependency>
>                  
><groupId>commons-io</groupId>
>                  
><artifactId>commons-io</artifactId>
>                                                <version>2.4</version>
>                                </dependency>
>                                <dependency>
>                  
><groupId>commons-lang</groupId>
>                  
><artifactId>commons-lang</artifactId>
>                                                <version>2.6</version>
>                                </dependency>
>                                <dependency>
>                  
><groupId>javax.activation</groupId>
>                  
><artifactId>activation</artifactId>
>                  
><version>1.1-rev-1</version>
>                                </dependency>
>                                 <dependency>
>              <groupId>com.twmacinta</groupId>
>              <artifactId>fast-md5</artifactId>
>              <version>2.7.1</version>
>  </dependency>
></dependencies>
>
>I set up a module to generate an OSGi bundle from this library. Here is
>my configuration:
>
>            <plugin>
>                <groupId>org.apache.felix</groupId>
>                <artifactId>maven-bundle-plugin</artifactId>
>                <version>2.5.4</version>
>                <extensions>true</extensions>
>                <configuration>
>                    <obrRepository>NONE</obrRepository>
>                    <manifestLocation>META-INF</manifestLocation>
>                    <instructions>
>                  
><Export-Package>com.idexx.imaging*</Export-Package>
>                        <Import-Package>
>
>                  
>!com.sun*;!junit*;!jgoodies*;!net.sf*;!org.apache.aries*;!org.apache.avalo
>n*;
>                  
>!org.apache.axiom*;!org.apache.cxf.tools.common*;!org.apache.cxf.tools.val
>idator*;
>                  
>!org.apache.geronimo*;!org.apache.log*;!org.apache.mina*;!org.junit*;!org.
>jvnet*;
>                  
>!org.osgi.service*;!org.relaxng*;!org.springframework*;
>                            *
>                        </Import-Package>
>                        <Embed-Dependency>
>                            !org.apache.felix*;*;scope=compile|runtime
>                        </Embed-Dependency>
>                        <Embed-Transitive>true</Embed-Transitive>
>                  
><Bundle-ClassPath>{maven-dependencies},.</Bundle-ClassPath>
>                    </instructions>
>                </configuration>
>                <executions>
>                                ...
>            </plugin>
>
>My question is about that long list of Import-Package exclusions. When I
>initially ran my OSGi bundle in Felix it complained about missing
>dependencies. I arrived at this list by iteratively excluding things
>until I came to a configuration that worked. Why are there so many things
>I need to exclude? Shouldn't these dependencies be picked up by the
>Embed-Transitive flag? They can't really all be dynamic dependencies, can
>they? Could an incorrect POM file provided by the other team be part of
>this? Any insight is greatly appreciated. Thanks!
>



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