Solved

Launching an OSGi runtime in a Application

Posted on 2009-07-07
6
311 Views
Last Modified: 2013-12-15
Hi Everyone,

I am trying to create an OSGi runtime within my application and according to the following website:
http://mathiasrichter.blogspot.com/2008/04/how-to-launch-osgi-runtime-in-your.html
I should be able to do it. However, I am getting the following error when I run the code:

Exception in thread "main" java.lang.NullPointerException
      at java.io.File.<init>(Unknown Source)
      at org.eclipse.osgi.internal.baseadaptor.BaseStorage.getBundleContent(BaseStorage.java:595)
      at org.eclipse.osgi.internal.baseadaptor.BaseStorage.createBundleFile(BaseStorage.java:604)
      at org.eclipse.osgi.baseadaptor.BaseAdaptor.createBundleFile(BaseAdaptor.java:491)
      at org.eclipse.osgi.baseadaptor.BaseData.getBundleFile(BaseData.java:393)
      at org.eclipse.osgi.baseadaptor.BaseData.getEntry(BaseData.java:96)
      at org.eclipse.osgi.framework.internal.core.AbstractBundle.getEntry(AbstractBundle.java:1305)
      at org.eclipse.osgi.framework.internal.core.Framework.findInSystemBundle(Framework.java:502)
      at org.eclipse.osgi.framework.internal.core.Framework.findVMProfile(Framework.java:448)
      at org.eclipse.osgi.framework.internal.core.Framework.loadVMProfile(Framework.java:364)
      at org.eclipse.osgi.framework.internal.core.Framework.initialize(Framework.java:223)
      at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:147)
      at org.eclipse.osgi.framework.internal.core.OSGi.createFramework(OSGi.java:90)
      at org.eclipse.osgi.framework.internal.core.OSGi.<init>(OSGi.java:31)
      at com.lmco.gcm.translator_main.App.launchFramework(App.java:25)
      at com.lmco.gcm.translator_main.App.main(App.java:16)

So, I am not sure what is going on. Please let me know if you have any advice on what could be going wrong.

Thanks,
Stephen
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.eclipse.osgi.framework.internal.core.OSGi;
...
 
/*** Launch the OSGi framework.** 
@param installArea Directory path to where the OSGi bundles remain.* 
@param configArea Direcotory path to where OSGi should store its configuration                data.
*/
 
public void launchOsgi( String installArea, String configArea ) { 
   System.setProperty( "osgi.install.area", installArea ); 
   System.setProperty( "osgi.configuration.area", configArea ); 
   FrameworkAdaptor adaptor = new BaseAdaptor( null );
   OSGi osgiInstance = new OSGi( adaptor );
   osgiInstance.launch();
}

Open in new window

0
Comment
Question by:stjowa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:alainbryden
ID: 24798536
It looks like it might be a linking error. Are you running with osgi as a jar or is in in your workspace?

--
Alain
0
 

Author Comment

by:stjowa
ID: 24798961
I have included the osgi as a jar and as a Maven dependency. It doesn't seem like that would cause this issue, but do you have any suggestions with that?
0
 
LVL 92

Expert Comment

by:objects
ID: 24799406
where are you pointing install and config areas?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:stjowa
ID: 24800173
Hey objects,

Yeah, that was actually one of the questions that I was wandering about. Where are you suppose to assign those properties?
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 24800186
sounds like thats your problem then :)
What they are is stated in the javadoc

@param installArea Directory path to where the OSGi bundles remain.
@param configArea Direcotory path to where OSGi should store its configuration  data.
0
 

Author Comment

by:stjowa
ID: 24802928
Ok, but what does "path to where the OSGi bundles remain" exactly mean? Is it where the osgi framework jar is located or is it where osgi bundles should be installed after the runtime is loaded? Also what about "path to where OSGi should store its configuration data"? Can this just be any location you choose or does it have to be a specific path?

Thanks.
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question