Missing required bundle org.eclipse.core.databinding.beans_0.0.0
开发环境:
eclipse 3.7.1 RCP SDK
问题产生过程:
新建eclipse RCP工程,使用windowbuilder设计editor界面,将某控件(如:label)进行数据绑定。
eclipse 后台生成代码:
protected DataBindingContext initDataBindings() {
DataBindingContext bindingContext = new DataBindingContext();
IObservableValue lblSysNoObserveTextObserveWidget = SWTObservables.observeText(lblSysNo);
IObservableValue sysContextSysTypesystemNameObserveValue = PojoObservables.observeValue(sysContext, "sysType.systemNo");
bindingContext.bindValue(lblSysNoObserveTextObserveWidget, sysContextSysTypesystemNameObserveValue, null, null);
return bindingContext;
DataBindingContext bindingContext = new DataBindingContext();
IObservableValue lblSysNoObserveTextObserveWidget = SWTObservables.observeText(lblSysNo);
IObservableValue sysContextSysTypesystemNameObserveValue = PojoObservables.observeValue(sysContext, "sysType.systemNo");
bindingContext.bindValue(lblSysNoObserveTextObserveWidget, sysContextSysTypesystemNameObserveValue, null, null);
return bindingContext;
}
保存程序后运行代码出现一下错误信息。
错误信息:
!SESSION 2011-11-22 22:58:20.305 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_22
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=zh_CN
Framework arguments: -application teshost.application
Command-line arguments: -application teshost.application -data D:\work\src/../runtime-teshost.application -dev file:D:/work/src/.metadata/.plugins/org.eclipse.pde.core/teshost.application/dev.properties -os win32 -ws win32 -arch x86 -consoleLog
!ENTRY org.eclipse.osgi 2 0 2011-11-22 22:58:21.360
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2011-11-22 22:58:21.360
!MESSAGE Bundle initial@reference:file:http://www.cnblogs.com/work/src/teshost/ was not resolved.
!SUBENTRY 2 teshost 2 0 2011-11-22 22:58:21.360
!MESSAGE Missing required bundle org.eclipse.core.databinding.beans_0.0.0.
!ENTRY org.eclipse.osgi 2 0 2011-11-22 22:58:21.361
!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 2011-11-22 22:58:21.362
!MESSAGE Bundle teshost_1.0.0 [38] was not resolved.
!SUBENTRY 2 teshost 2 0 2011-11-22 22:58:21.362
!MESSAGE Missing required bundle org.eclipse.core.databinding.beans_0.0.0.
!ENTRY org.eclipse.osgi 2 0 2011-11-22 22:58:21.371
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2011-11-22 22:58:21.371
!MESSAGE Bundle initial@reference:file:http://www.cnblogs.com/work/src/teshost/ was not resolved.
!SUBENTRY 2 teshost 2 0 2011-11-22 22:58:21.372
!MESSAGE Missing required bundle org.eclipse.core.databinding.beans_0.0.0.
!ENTRY org.eclipse.osgi 2 0 2011-11-22 22:58:21.373
!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 2011-11-22 22:58:21.373
!MESSAGE Bundle teshost_1.0.0 [38] was not resolved.
!SUBENTRY 2 teshost 2 0 2011-11-22 22:58:21.373
!MESSAGE Missing required bundle org.eclipse.core.databinding.beans_0.0.0.
!ENTRY org.eclipse.osgi 4 0 2011-11-22 22:58:21.374
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: Application "teshost.application" could not be found in the registry. The applications available are: org.eclipse.equinox.app.error.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:248)
at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
An error has occurred. See the log file
错误原因:
生成的绑定代码中,PojoObservables 来自于
org.eclipse.core.databinding.beans jar包。这个jar包本在 Plug-in Dependencies中,但是项目无论如何加载不了,具体错误原因不明,跟进代码调试,会报异常:
java.lang.RuntimeException: No application id has been found.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:242)
解决方法:
1. 找到eclipse安装目录下的对应jar包, 如: d:\eclipse-SDK-3.7.1-win32\eclipse\plugins\org.eclipse.core.databinding.beans_1.2.100.I20100824-0800.jar
2. 将该jar包以外部jar包形式添加到项目引用(Add Extenal JARS...)
3. 将 jar包copy到项目下的lib文件夹下
4. 打开项目的MANIFEST.MF文件,转到MANIFEST.MF Tab页面
5. 删除依赖项:
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.databinding,
org.eclipse.core.databinding.beans, //删除这一行,由于第2部的原因,项目生成代码不会因为找到命名空间而报错。
org.eclipse.core.databinding.observable,
org.eclipse.core.databinding.property,
org.eclipse.jface.databinding
6. 分别在runtime 和 build tab页面中添加jar包的引用
7. 重新启动执行,问题解决
PS: 该问题具体原因不明,有可能是RCP的一个bug。