当尝试以Equinox方式编程安装一个bundle时,nullPointerException [英] nullPointerException when trying to programmatically install a bundle in Equinox
本文介绍了当尝试以Equinox方式编程安装一个bundle时,nullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
NullPointerExceptions
这里是堆栈跟踪... 异常在线程mainjava.lang.NullPointerException
在org.eclipse.osgi.internal.baseadaptor.BaseStorageHook.mapLocationToURLConnection(BaseStorageHook.java:372)
在org.eclipse.osgi.baseadaptor.BaseAdaptor。 mapLocationToURLConnection(BaseAdaptor.java:185)
在org.eclipse.osgi.framework.internal.core.Framework $ 1.run(Framework.java:835)
在java.security.AccessController.doPrivileged(Native方法)
在org.eclipse.osgi.framework.internal.core.Framework.installWorker(Framework.java:888)
在org.eclipse.osgi.framework.internal.core.Framework.installBundle( Framework.java:832)
在org.eclipse.osgi.framework.internal.core.BundleContextImpl.installBundle(BundleContextImpl.java:167)
在org.eclipse.osgi.framework.internal.core。 BundleContextImpl.installBundle(BundleContextImpl.java:161)
在com.mydemo.bootstrap.Boot strap.main(Bootstrap.java:35)
这里是代码...
public class Bootstrap
{
public static void main(String [] args)throws BundleException,InterruptedException ,MalformedURLException
{
//加载框架工厂
ServiceLoader loader = ServiceLoader.load(FrameworkFactory.class);
FrameworkFactory factory =(FrameworkFactory)loader.iterator().next();
//创建框架的新实例
Framework framework = factory.newFramework(null);
try
{
//启动框架
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
{
//停止框架
framework.stop();
//等待框架完全停止
framework.waitForStop(3000);
}
}
}
解决方案
我很确定start()和init()应该是相反的顺序。
//初始化框架
framework.init();
//启动框架
framework.start();
I'm trying to do a simple demo where I start the Equinox Framework and then load a tutorial bundle that was created (via the tutorial). I keep getting NullPointerExceptions
here is the stack trace...
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)
here is the code ...
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 );
}
}
}
解决方案
I am pretty sure that start() and init() should be in the opposite order.
// Initialize the framework
framework.init( );
// Start the framework
framework.start( );
这篇关于当尝试以Equinox方式编程安装一个bundle时,nullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文