尝试以编程方式在 Equinox 中安装包时出现 nullPointerException
我正在尝试做一个简单的演示,在其中启动 Equinox 框架,然后加载创建的教程包(通过教程)。我不断收到 NullPointerExceptions
这是堆栈跟踪...
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 );
}
}
}
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 );
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很确定 start() 和 init() 应该采用相反的顺序。
I am pretty sure that start() and init() should be in the opposite order.
我也遇到了这个问题,我发现使用 apache felix 而不是 equinox 作为 OSGi 框架时不会出现此错误。
这并不是一个真正的解释,但切换到 felix 可能是一个可能的解决方法。
I ran into this problem as well, and I found that you don't get this error when using apache felix instead of equinox as the OSGi framework.
It's not really an explanation, but switching to felix might be a possible workaround.