2009/9/29 Joel Schuster <[email protected]> > There have been a couple of times where I've been using systems where the > package/class that I'm trying to use is being loaded dynamically. > > For example, the 'standard' way to use a JDBC driver is something like > this: > > String driverName = "oracle.jdbc.driver.OracleDriver"; > Class.forName(driverName); > > Or in the case of Jaxb and using JAXBContext with a marshaller: > > JAXBContext jaxbContext = JAXBContext.newInstance( contextName); > > In both these cases I've had a really hard time forcing the bnd ant task to > have Imports for the packages I need. Including them like this doesn't work: > > Import-Package: oracle.jdbc.driver.* >
Hi Joel, this is actually working as designed... The standard OSGi Import-Package header does not support wildcards, but to help developers bnd does accept wildcards which it matches against any packages discovered during analysis. Only matched packages are added to the generated import list - so if you use this wildcard: Import-Package: oracle.jdbc.driver.* and no packages match it during analysis then nothing will be added to the generated list. To force bnd to add a package you need to use a non-wildcard entry: Import-Package: oracle.jdbc.driver, * Also note that I've kept the default import wildcard (ie. *) at the end so bnd knows to add any discovered packages automatically - otherwise you would just end up with the oracle package on your final generated Import-Package, which is probably not what you want HTH Instead I've had to explicitly create a 'fake' instance of the Driver > (literally, new oracle.jdbc.driver.OracleDriver()) so that it's included in > the imports and then bnd seems to be able to pick it up. > > There has got to be a better way. What am I missing? > > ________________________________ > > Joel Schuster > Senior Software Engineer > NAVSYS Corporation > 14960 Woodcarver Road, Colorado Springs, CO 80921 > 719-481-4877 > -- Cheers, Stuart

