Solved

Launching an OSGi runtime in a Application

Posted on 2009-07-07
6
304 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

763 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