Solved

Launching an OSGi runtime in a Application

Posted on 2009-07-07
6
297 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now