users@glassfish.java.net

How to import packages from osgi bundle

From: Peter Penzov <peter.penzov_at_gmail.com>
Date: Sat, 9 Jun 2012 19:22:59 +0300

Hi,
   I want to deploy Primefaces as OSGI bundle and use it for my OSGI
application. This is the Manifest file of the Primefaces.jar:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven Bundle Plugin
Built-By: jagatai
Build-Jdk: 1.6.0_31
Export-Package: org.primefaces.component.ring;uses:="javax.el,javax.fa
 ces.component,javax.faces.application,javax.faces.context,org.primefa
 ........
 org.primefaces.component.chart,javax.faces.application,javax.faces.co
 ntext,org.primefaces.component.api,org.primefaces.model.chart,javax.f
 aces.component.behavior";version="3.3"
Bundle-Version: 3.3.0
Tool: Bnd-1.43.0
Bundle-Name: primefaces
Bnd-LastModified: 1338230530728
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.primefaces
Import-Package: com.lowagie.text;resolution:=optional,com.lowagie.text
 .pdf;resolution:=optional,com.sun.syndication.feed.synd;resolution:=o
 .........
 esolution:=optional;version="[1.2,2)",org.apache.poi.hssf.usermodel;r
 esolution:=optional,org.apache.poi.ss.usermodel;resolution:=optional,
 org.eclipse.jetty.websocket;resolution:=optional;version="[8.0,9)"

I can successfully deploy it on Glassfish as OSGI bundle.

I created WAB file which uses JSF. This is part of the POM file:

<plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.3.7</version>
                    <extensions>true</extensions>
                    <configuration>
                        <supportedProjectTypes>
                            <supportedProjectType>ejb</supportedProjectType>
                            <supportedProjectType>war</supportedProjectType>

<supportedProjectType>bundle</supportedProjectType>
                            <supportedProjectType>jar</supportedProjectType>
                        </supportedProjectTypes>
                        <instructions>
                            <!-- Read all OSGi configuration info from this
optional file -->
                            <_include>-osgi.properties</_include>
                            <!-- By default, we don't export anything -->
                            <Export-Package></Export-Package>
                            <DynamicImport-Package>*</DynamicImport-Package>
                            <Import-Package>*</Import-Package>

<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
                            <Embed-Transitive>true</Embed-Transitive>
                            <Embed-StripVersion>false</Embed-StripVersion>
                            <Embed-StripGroup>true</Embed-StripGroup>

<Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
                        </instructions>
                    </configuration>
                    <executions>
                        <execution>
                            <id>bundle-manifest</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>manifest</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>bundle-install</id>
                            <phase>install</phase>
                            <goals>
                                <goal>install</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

I have imported all external packages. But when I open web page which
includes Primefaces I get "not found". It seems that the library is not
properly included. I use this configuration to import the Primefaces.jar:

       <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.3</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>

Would you tell me please where I'm wrong?