2011-06-29 21 views
3

私はEquinox Frameworkを起動して、チュートリアルで作成したチュートリアルバンドルを読み込む簡単なデモをしようとしています。私はここNullPointerExceptionsを取得し、スタックトレースです...ここ EquinoxでバンドルをプログラムでインストールしようとするとnullPointerExceptionが発生する

Exception in thread "main" java.lang.NullPointerException 
    at org.eclipse.osgi.internal.baseadaptor.BaseStorageHook.mapLocationToURLConnection(BaseStorageHook.java:372) 
    at org.eclipse.osgi.baseadaptor.BaseAdaptor.mapLocationToURLConnection(BaseAdaptor.java:185) 
    at org.eclipse.osgi.framework.internal.core.Framework$1.run(Framework.java:835) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at org.eclipse.osgi.framework.internal.core.Framework.installWorker(Framework.java:888) 
    at org.eclipse.osgi.framework.internal.core.Framework.installBundle(Framework.java:832) 
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.installBundle(BundleContextImpl.java:167) 
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.installBundle(BundleContextImpl.java:161) 
    at com.mydemo.bootstrap.Bootstrap.main(Bootstrap.java:35) 

がコードです...

public class Bootstrap 
{ 

public static void main(String[ ] args) throws BundleException , InterruptedException , MalformedURLException 
{ 

    // Load the framwork factory 
    ServiceLoader loader = ServiceLoader.load(FrameworkFactory.class); 
    FrameworkFactory factory = (FrameworkFactory) loader.iterator().next(); 

    // Create a new instance of the framework 
    Framework framework = factory.newFramework(null); 

    try 
    { 
     // Start the framework 
     framework.start(); 
     framework.init(); 

     BundleContext bc = framework.getBundleContext(); 
     bc.installBundle("file:/c:/Users/kirk/Desktop/plugins/org.equinoxosgi.toast.client.emergency_1.0.0.201106290845.jar"); 
    } 
    finally 
    { 
     // Stop the framework 
     framework.stop(); 

     // Wait for the framework to stop completely 
     framework.waitForStop(3000); 
    } 
} 
} 

答えて

0

私もこの問題に走った、と私はあなたが取得しないことを発見し続けますこのエラーは、OSGiフレームワークとしての春分の代わりにapache felixを使用した場合に発生します。

これは実際の説明ではありませんが、フェリックスへの切り替えは回避策になる可能性があります。

0

私はstart()とinit()が逆の順序でなければならないと確信しています。

// Initialize the framework 
framework.init(); 

// Start the framework 
framework.start(); 
関連する問題