Erik Peterson wrote:
Okay, this is very enlightening. So in my case of creating an H2 database module: 1) A few packages have compile time only dependencies...unless the H2 deployment specifically uses those 3rd party features (e.g., org.lucene). So, this is what you refer to as an optional dependency right?

Sounds like it, but if they can actually be used at run time, then they are not really optional. They might be optional for your use case (i.e., you don't use them), but they are not optional. However, you can still mark them as optional, but any users of this functionality would have to be prepared to catch exceptions if the packages are not actually available at run time.

2) Is there an "optional" flag for the <Import-Package> section or some other way to declare org.lucene as optional.

Yes, you would do something like <Import-Package>org.lucence;resolution:=optional,*</Import-Package> or something like that...correct me if I am wrong Stuart. :-)

3) If I declare lucene optional and don't package it, but then the user does wants to use the lucene features, I need to instruct them to add the package to the proper vm sections(s) of the conf/config.properties file? Or is their some other way?

Well, if they can be deployed as a bundle, then they can be made available that way. Otherwise, yes, they would have to be added in the same way you add your other packages.

You should always package everything as bundles with proper imports/exports if you can. Your original question referred to com.sun packages, which you might not be able to package as a bundle, but everything else would be better in a bundle if possible.

-> richard


Thanks!
Erik

On May 29, 2008, at 12:40 AM, Richard S. Hall wrote:

I would recommend option (b), since (a) hides the dependency, which will cause your bundle to fail on other frameworks or even misconfigured installations of Felix and you won't easily know why. Better to have your dependencies be explicit, so that people will know how to satisfy them.

-> richard

Erik Peterson wrote:
That did the trick! I just removed the imports using option a.

Now I have to look at what makes since in separating the current bundle into separate services: tcp server, embedded server, mixed mode, web console etc. What I'm really interested in is deploying in mixed mode (embedded and tcp db server) to get the in-vm speed advantages but still connect from external tools. Using felix I can do that now and deploy multiple services that take advantage of an embedded db.

Thanks again!

Erik


On May 28, 2008, at 1:18 PM, Karl Pauls wrote:

The issue is that the packages are not exported by the system bundle.
You can do one of the following two things:

a) remove the import from your bundle i.e.,

<Import-Package>
    !., !com.sun.*, !sun.*,*
</Import-Package>

and add/uncomment the following line in conf/config.properties

org.osgi.framework.bootdelegation=sun.*,com.sun.*

or b) add the required packages to the system bundle exports. That can
be done in the conf/config.properties as well by adding it to the Java
platform package export properties. Make sure you add it to the list
that matches your version of java.

It's hard to say which approach is preferable - there are pro and cons
to both. Are you sure your bundle really needs the packages or is it
an optional dependency? Maybe just remove the import and don't add the
bootdelegation line. Then see whether your bundle does run without
access to the packages. If that is the case go with option b) but mark
the import as optional.

regards,

Karl

On Wed, May 28, 2008 at 5:16 PM, Erik Peterson <[EMAIL PROTECTED]> wrote:
I'm new to osgi/felix and am trying to wrap h2 database as an iPOJO bundle.
When starting the service from felix console I get:
"org.osgi.framework.BundleException: Unresolved package in bundle 24:
package; (package=com.sun.tools.javac)"
I'm on Mac OS X 10.5 (Leopard) which, to my understanding, includes this package in the runtime. So there is no tools.jar that needs to be imported.

Any ideas how to get this working?
Thanks!
Erik


fyi...here is the pom file I'm using if that has any impact...

<project>
 <modelVersion>4.0.0</modelVersion>
 <packaging>bundle</packaging><!-- Use the BND Maven plug-in -->
 <groupId>ipojo.examples</groupId>
 <artifactId>hello.client</artifactId>
 <version>0.8.0-SNAPSHOT</version>
 <name>Hello Service Client</name>
 <dependencies>
     <dependency>
         <groupId>ipojo.examples</groupId>
         <artifactId>hello.service</artifactId>
         <version>0.8.0-SNAPSHOT</version>
     </dependency>
     <dependency>
         <groupId>com.h2database</groupId>
         <artifactId>h2</artifactId>
         <version>1.0.72</version>
         <scope>compile</scope>
     </dependency>
 </dependencies>
 <pluginRepositories>
     <pluginRepository>
         <id>apache.snapshots</id>
         <name>snapshot plugins</name>
         <url>

http://people.apache.org/repo/m2-snapshot-repository
         </url>
         <releases>
             <enabled>false</enabled>
         </releases>
         <snapshots>
             <enabled>true</enabled>
         </snapshots>
     </pluginRepository>
 </pluginRepositories>
 <build>
     <plugins>

         <plugin>
             <groupId>org.apache.felix</groupId>
             <artifactId>maven-bundle-plugin</artifactId>
             <extensions>true</extensions>
             <version>1.4.1</version>
             <configuration>
                 <instructions>
                     <Bundle-SymbolicName>
${pom.artifactId}
                     </Bundle-SymbolicName>
                     <Private-Package>

ipojo.example.hello.client
                     </Private-Package>
<!--
                     <Private-Package>
                                                     org.h2.*,
ipojo.example.hello.client
                     </Private-Package>
                     -->
                     <Export-Package>
                         *
                     </Export-Package>
                     <Import-Package>
                         !., *
                     </Import-Package>

                 </instructions>
             </configuration>
         </plugin>
         <plugin>
             <groupId>org.apache.felix</groupId>
             <artifactId>maven-ipojo-plugin</artifactId>
             <version>0.8.0-SNAPSHOT</version>
             <executions>
                 <execution>
                     <goals>
                         <goal>ipojo-bundle</goal>
                     </goals>
                 </execution>
             </executions>
         </plugin>
     </plugins>
 </build>
</project>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Karl Pauls
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to