背景介绍
这两天应XMan团队的需求开始研究基于JavaFX的E4 RCP 。
这里先推荐一个很好的(英文)入门教程(中文系列教程实在没有找到):
http://developer.eclipsesource.com/tutorials/#eclipse4
在学习Model Fragment部分时,根据提示使用"Extract into a fragment"时,导致项目无法正确运行,报错:
!ENTRY org.eclipse.equinox.app 0 0 2016-04-06 18:56:17.546
!MESSAGE Product App4.app.product could not be found.!ENTRY org.eclipse.xtend.lib 2 0 2016-04-06 18:56:17.620
!MESSAGE Could not resolve module: org.eclipse.xtend.lib [157]
Unresolved requirement: Require-Bundle: org.eclipse.xtend.lib.macro; bundle-version="[2.9.0,3.0.0)"; visibility:="reexport"
!ENTRY org.eclipse.osgi 4 0 2016-04-06 18:56:17.621
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: No application id has been found.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:242)
at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
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:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
gogo: InterruptedException: sleep interrupted
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:72)
at java.lang.Thread.run(Unknown Source)
因为我是才开始使用Eclipse进行E4 RCP的开发,对工程之间的环境也了解不足,提示已经很明确了"No application id has been found.",但我还是不知道应该如何解决,搜索了很久也没有找到适合我这个具体问题的解决方案。
解决方案
经过一番搜索后没有找到答案,我只能自己研究研究。于是重新创建一套正确的工程后,再手动创建一个Model Fragment,依然有同样的问题。
于是我就查了一下新建Model Fragment时新增了1个文件,另外只有2个配置文件发生了变化,build.properties和plugin.xml,内容如下:
build.properties
bin.includes = .,\ META-INF/,\ plugin.xml,\ css/,\ Application.e4xmi,\ OSGI-INF/,\ fragment.e4xmi source.. = src/
plugin.xml
<?xml version="1.0" encoding="UTF-8"?> <plugin> <extension point="org.eclipse.core.runtime.products"> <product name="test" application="org.eclipse.fx.ui.workbench.fx.application"> <property name="appName" value="test"></property> <property name="applicationXMI" value="App4.app/Application.e4xmi"></property> <property name="cssTheme" value="theme.default"></property> </product> </extension> <extension id="App4.app.fragment" point="org.eclipse.e4.workbench.model"> <fragment uri="fragment.e4xmi"></fragment> </extension> </plugin>
初始plugin.xml
<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.0"?> <plugin> <extension id="product" point="org.eclipse.core.runtime.products"> <product name="test" application="org.eclipse.fx.ui.workbench.fx.application" > <property name="appName" value="test" /> <property name="applicationXMI" value="App3.app/Application.e4xmi" /> <property name="cssTheme" value="theme.default" /> </product> </extension> </plugin>
有较大区别的在plugin.xml,除了新增了一个extension标签配置fragment.e4xmi外,顶部的<?eclipse version="3.0"?>丢失了,最重要的是原始的extension中的id信息丢失了。
我手动将id="product"加回来,问题就解决了!
http://www.alanzeng.cn/2016/04/javafx-e4-rcp-model-fragment-no-application-id-has-been-found/