Community
Participate
Working Groups
Build Identifier: 3.8.0.v20120430-1750 Hi, we're currently trying to embed equinox and start it programatically. Everything works fine if Equinox is stored externally in e.g. a lib directory and then adding it to the classpath via java -cp lib/org.eclipse.osgi-3.8.0.v20120430-1750.jar or an entry in the manifest file. But if we're trying to add the equinox dependency into the jar which is launching the framework we're getting the following error while trying to install the first bundle: Exception in thread "main" java.lang.NullPointerException at org.eclipse.osgi.internal.baseadaptor.BaseStorageHook.mapLocationToURLConnection(BaseStorageHook.java:385) at org.eclipse.osgi.baseadaptor.BaseAdaptor.mapLocationToURLConnection(BaseAdaptor.java:195) at org.eclipse.osgi.framework.internal.core.Framework$1.run(Framework.java:844) at org.eclipse.osgi.framework.internal.core.Framework$1.run(Framework.java:1) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.Framework.installWorker(Framework.java:905) at org.eclipse.osgi.framework.internal.core.Framework.installBundle(Framework.java:841) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.installBundle(BundleContextImpl.java:137) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.installBundle(BundleContextImpl.java:131) at org.ogema.launcher.OgemaFramework.start(OgemaFramework.java:73) at org.ogema.launcher.OgemaLauncher.start(OgemaLauncher.java:162) at org.ogema.launcher.OgemaLauncher.main(OgemaLauncher.java:313) Additionally the system bundle is shown as unknown: osgi> ss id State Bundle 0 ACTIVE unknown_0.0.0 [0] We're using maven to package the jar... pom for the specific project looks like this: <project ... > <parent> <groupId>de.iwes</groupId> <artifactId>iwes-bundles</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>org.ogema</groupId> <artifactId>ogema-launcher</artifactId> <dependencies> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <version>4.3.0</version> </dependency> <dependency> <groupId>org.eclipse.tycho</groupId> <artifactId>org.eclipse.osgi</artifactId> <version>3.8.0.v20120430-1750</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>org.ogema.launcher.OgemaLauncher</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project> maven-jar-plugin and maven-assembly-plugin are defined in the parent pom: ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>${maven-jar-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.3</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> ... Other OSGi frameworks are working fine with the same configuration and code... but we're mainly using equinox and would rather like to use this solution (including dependencies in the jar). The Java code that we're running to start the framework: ... FrameworkFactory frameworkFactory = ServiceLoader.load( FrameworkFactory.class).iterator().next(); // cfg is a configuration object Framework framework = frameworkFactory.newFramework(cfg.getFrameworkConfig()); ... try { framework.start(); BundleContext context = framework.getBundleContext(); for(BundleInfo bi : cfg.getAvailableBundles()) { URI uri = bi.getBundleLocation(); try { tmp.put(context.installBundle(uri.toString()), Boolean.valueOf(bi.shouldBeStarted())); installedBundles.put(Integer.valueOf(bi.getStartLevel()), tmp); } catch(BundleException e) { System.err.println("Failed to install: " + uri + "\n Reason: " + e.getMessage()); } catch (BundleException e) { System.err.println("Failed to start framework. Reason:); e.printStackTrace(); } // start bundles ... Any help/feedback would be appreciated. Ty. Regards Reproducible: Always Steps to Reproduce: 1. Create a maven project 2. Add equinox as dependency and use the mvn assembly plugin or the maven-dependency-plugin to add the dependencies into the jar 3. Start the framework programatically (like we've done - described in the bug report) 4. Try to install at least one bundle
Could you attach an example launcher that embeds equinox? My initial guess is that we no longer have the framework META-INF/MANIFEST.MF that contains the frameworks "bundle manifest". I say this because the console seems to report an "unknown" symbolic name for the framework itself. I imagine this could cause all kinds of strange issues.
Hi Thomas, sorry for the late answer. Will do that in the next few days... just came back from vacation.
Please reopen if you still see the problem and provide the example launcher requested in comment 1.