R-OSGi实现分布式OSGi应用,demo出错了

HaoBiaoSheng 2016-02-25 09:52:29
用R-OSGi实现分布式OSGi应用
1、这是服务端bundle,目录结构如下图所示:

这是服务端bundle主类:

这是MANIFEST.MF文件:


2、这是客户端bundle,目录结构如下图所示:

这是客户端bundle主类:
public class Activator implements BundleActivator {

private static BundleContext context;
private ServiceReference sref;
private static RemoteOSGiService remote;
private static ServiceInterface service;
private static final URI uri = new URI(System.getProperty(
"ch.ethz.iks.r_osgi.service.uri", "r-osgi://10.255.22.165:9278")); // IP地址根据服务所在的机器作相应调整

static BundleContext getContext() {
return context;
}

public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;

System.out.println("starting sample client");
sref = context.getServiceReference(RemoteOSGiService.class.getName());
if (sref != null) {
remote = (RemoteOSGiService) context.getService(sref);
} else {
throw new BundleException("OSGi remote service is not present.");
}

final RemoteServiceReference[] refs = remote.getRemoteServiceReferences(uri,
ServiceInterface.class.getName(), null);
if (refs==null) {
throw new BundleException("The service is not present.");
}
System.out.println("I am client bundle\n");
System.out.println("Wait...\n");
service = (ServiceInterface) remote.getRemoteService(refs[0]);
System.out.println(service.getMessage());

}

public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}

3、先运行服务端bundle,是没有问题的,但是运行客户端bundle时,就出现错误了:
!SESSION 2016-02-25 09:07:32.389 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_15
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=zh_CN
Command-line arguments: -dev file:E:/android/.metadata/.plugins/org.eclipse.pde.core/ROSGi2/dev.properties -os win32 -ws win32 -arch x86 -consoleLog -console

!ENTRY rosgi_client 4 0 2016-02-25 09:07:33.805
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "rosgi_client_1.0.0.qualifier [8]" could not be resolved. Reason: Missing Constraint: Import-Package: rosgi_service_api; version="0.0.0"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

!ENTRY org.eclipse.osgi 4 0 2016-02-25 09:07:33.833
!MESSAGE Bundle initial@reference:file:E:/android/rosgi_client/ was not resolved.

!ENTRY org.eclipse.osgi 2 0 2016-02-25 09:07:33.861
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2016-02-25 09:07:33.863
!MESSAGE Bundle initial@reference:file:E:/android/rosgi_client/ was not resolved.
!SUBENTRY 2 rosgi_client 2 0 2016-02-25 09:07:33.865
!MESSAGE Missing imported package rosgi_service_api_0.0.0.

!ENTRY org.eclipse.osgi 2 0 2016-02-25 09:07:33.869
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2016-02-25 09:07:33.872
!MESSAGE Bundle rosgi_client_1.0.0.qualifier [8] was not resolved.
!SUBENTRY 2 rosgi_client 2 0 2016-02-25 09:07:33.874
!MESSAGE Missing optionally imported package ch.ethz.iks.r_osgi_0.0.0.
!SUBENTRY 2 rosgi_client 2 0 2016-02-25 09:07:33.877
!MESSAGE Missing imported package rosgi_service_api_0.0.0.
osgi>

4不知道是什么问题,麻烦各位大神帮忙解决下。
...全文
1944 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,151

社区成员

发帖
与我相关
我的任务
社区描述
该论坛主要探讨基于IBM云计算的开发技术,并为网友们提供自由交流的平台。
社区管理员
  • IBM云计算社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧