Solved

Launching an OSGi runtime in a Application

Posted on 2009-07-07
6
302 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
  • 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

803 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