dev@glassfish.java.net

pom.xml help?

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Fri, 11 Jul 2008 21:43:11 -0700

I am trying to repackage an external jar file (dataprovider.jar) to be
an OSGi bundle. This jar file has a class in it which depends on
"com.sun.sql.rowset". If you don't use that part of the functionality
(we don't), everything works just fine... so we haven't included
"dataprovider-rowset.jar" in GlassFish before. Question:

    How do I make this dependency not required?

When I attempt to deploy my app app which depends on the re-packaged
dataprovider.jar I get this error:
   
    at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
    at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:169)
Caused by: org.osgi.framework.BundleException: Unresolved package in
bundle 24: package; (package=com.sun.sql.rowset)
    at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1728)
    at org.apache.felix.framework.Felix._startBundle(Felix.java:1591)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1544)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:371)
    at
org.jvnet.hk2.osgiadapter.OSGiModuleImpl.resolve(OSGiModuleImpl.java:109)

The pom.xml file does this:

...
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        
<Embed-Dependency>artifactId=dataprovider;inline=true;</Embed-Dependency>
                        <Export-Package>com.sun.data.*;</Export-Package>
                    </instructions>
                </configuration>
                <executions>
                    <execution>
                        <id>osgi-bundle</id>
                        <phase>package</phase>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.sun.woodstock</groupId>
            <artifactId>dataprovider</artifactId>
            <version>1.4.2-SNAPSHOT</version>
        </dependency>
    </dependencies>

My MANIFEST.MF file for the repackaged dataprovider.jar is:

Manifest-Version: 1.0
Export-Package: com.sun.data.provider.impl;uses:="com.sun.sql.rowset,c
 om.sun.data.provider,javax.sql.rowset.serial,javax.sql,javax.sql.rows
 et.spi,javax.sql.rowset",com.sun.data.provider
Built-By: paulsen
Tool: Bnd-0.0.255
Bundle-Name: DataProvider
Created-By: Apache Maven Bundle Plugin
Bundle-Vendor: Sun Microsystems, Inc.
Build-Jdk: 1.6.0_06
Bundle-Version: 1.4.2.SNAPSHOT
Bnd-LastModified: 1215830659602
Bundle-ManifestVersion: 2
Bundle-License: https://glassfish.dev.java.net/nonav/public/CDDL+GPL.h
 tml
Bundle-Description: DataProvider Repackaged as OSGi bundle for GlassFi
 sh
Embed-Dependency: artifactId=dataprovider;inline=true;
Bundle-DocURL: http://www.sun.com
Bundle-SymbolicName: org.glassfish.admingui.dataprovider
Import-Package: com.sun.data.provider,com.sun.data.provider.impl,com.s
 un.sql.rowset,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,java
 x.sql.rowset.spi

I'd be happy if I could exclude the class that refers to this file from
repackaged bundle
(com/sun/data/provider/impl/CachedRowSetDataProvider.class), however, I
haven't figured out how to do that. Or if I can make the
dataprovider-rowset.jar optional (currently it's not even stored in a
maven repository as we've never used it before). Or any other way to do
this that causes it to ignore this dependency that I don't want to
have. Ideas?

Thanks,

Ken