Solved

Launching an OSGi runtime in a Application

Posted on 2009-07-07
6
305 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

739 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