E4 应用程序中的 H2 数据库无法解析
H2 Database in E4 Application not resolvable
我正在构建 E4 应用程序并希望使用 H2 数据库作为持久性存储。我记得,我必须在插件中放置一个外部库,以便能够从另一个插件或 rcp 应用程序访问它。
所以,我从 H2 网站下载了 jar 并按照此处描述的步骤操作:http://www.vogella.com/tutorials/EclipseJarToPlugin/article.html
我做了检查,一切看起来都很好,我在我原来的插件中包含了新插件。之后,这个原始插件的 MANIFEST.MF 看起来像这样:
> Bundle-SymbolicName: mhFinPim;singleton=true Bundle-Version:
> 1.0.0.qualifier Bundle-Name: mhFinPim Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle:
> org.eclipse.core.runtime;bundle-version="3.13.0",
> org.eclipse.swt;bundle-version="3.106.0",
> org.eclipse.e4.core.di;bundle-version="1.6.100",
> org.eclipse.e4.ui.di;bundle-version="1.2.100",
> org.eclipse.e4.core.di.extensions;bundle-version="0.15.0",
> org.eclipse.e4.ui.workbench;bundle-version="1.5.0",
> DatabaseH2;bundle-version="1.0.0"
新的H2数据库插件MANIFEST.MF是这个:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: DatabaseH2
Bundle-SymbolicName: DatabaseH2
Bundle-Version: 1.0.0
Bundle-ClassPath: h2-1.4.196.jar
Export-Package: org.h2,
org.h2.api,
org.h2.bnf,
org.h2.bnf.context,
org.h2.command,
org.h2.command.ddl,
org.h2.command.dml,
org.h2.compress,
org.h2.constraint,
org.h2.engine,
org.h2.expression,
org.h2.fulltext,
org.h2.index,
org.h2.jdbc,
org.h2.jdbcx,
org.h2.jmx,
org.h2.message,
org.h2.mvstore,
org.h2.mvstore.cache,
org.h2.mvstore.db,
org.h2.mvstore.rtree,
org.h2.mvstore.type,
org.h2.result,
org.h2.schema,
org.h2.security,
org.h2.server,
org.h2.server.pg,
org.h2.server.web,
org.h2.store,
org.h2.store.fs,
org.h2.table,
org.h2.tools,
org.h2.upgrade,
org.h2.util,
org.h2.value
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
完成所有这些步骤后,我启动了我的原始插件以查看它是否有效以及该插件是否可以与数据库一起使用。起初我从 eclipse 和下面的堆栈跟踪中收到这条消息:
!SESSION 2017-08-14 09:18:56.882 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_101
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments: -product mhFinPim.prod -clearPersistedState
Command-line arguments: -product mhFinPim.prod -data C:\Users\te_gza2g3_01\workspace/../runtime-ProdConf.product(1) -dev file:C:/Users/te_gza2g3_01/workspace/.metadata/.plugins/org.eclipse.pde.core/ProdConf.product (1)/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -clearPersistedState
!ENTRY org.eclipse.equinox.app 0 0 2017-08-14 09:18:58.547
!MESSAGE Product mhFinPim.prod could not be found.
!ENTRY mhFinPim 2 0 2017-08-14 09:18:58.663
!MESSAGE Could not resolve module: mhFinPim [5]
Unresolved requirement: Require-Bundle: DatabaseH2; bundle-version="1.0.0"
!ENTRY org.eclipse.osgi 4 0 2017-08-14 09:18:58.665
!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:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
gogo: IllegalStateException: session is closed
java.lang.IllegalStateException: session is closed
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:81)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
at java.lang.Thread.run(Thread.java:745)
在将新插件与数据库一起使用之前,应用程序启动时没有任何问题。如果我删除数据库插件,启动再次没有问题。所以,我想知道为什么 eclipse 现在告诉我,没有找到应用程序 ID,为什么找不到插件?!我是否必须添加任何内容来告诉 Eclipse,它可以在哪里找到插件?还是我弄乱了其他东西?
顺便说一句,为了提供完整的信息,这里是 plugin.xml 和产品配置:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="prod"
point="org.eclipse.core.runtime.products">
<product
application="org.eclipse.e4.ui.workbench.swt.E4Application"
name="FinPim">
<property
name="appName"
value="FinPim">
</property>
<property
name="lifeCycleURI"
value="bundleclass://mhFinPim/de.mho.finpim.lifecycle.Manager">
</property>
</product>
</extension>
</plugin>
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="FinPim" uid="ProdConf" id="mhFinPim.prod" application="org.eclipse.e4.ui.workbench.swt.E4Application" useFeatures="true" includeLaunchers="true">
<configIni use="default">
</configIni>
<launcherArgs>
<programArgs>-clearPersistedState
</programArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
</launcherArgs>
<launcher>
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
</vm>
<plugins>
</plugins>
<features>
<feature id="fpFeature"/>
<feature id="org.eclipse.e4.rcp"/>
<feature id="org.eclipse.emf.ecore"/>
<feature id="org.eclipse.emf.common"/>
</features>
<configurations>
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>
</product>
您必须将 DatabaseH2
插件包含在产品包含的插件列表中。
由于您使用的是基于功能的产品,因此您应该在您的功能中列出它 fpFeature
。在fpFeature
中打开feature.xml
并添加DatabaseH2
插件。
我正在构建 E4 应用程序并希望使用 H2 数据库作为持久性存储。我记得,我必须在插件中放置一个外部库,以便能够从另一个插件或 rcp 应用程序访问它。 所以,我从 H2 网站下载了 jar 并按照此处描述的步骤操作:http://www.vogella.com/tutorials/EclipseJarToPlugin/article.html 我做了检查,一切看起来都很好,我在我原来的插件中包含了新插件。之后,这个原始插件的 MANIFEST.MF 看起来像这样:
> Bundle-SymbolicName: mhFinPim;singleton=true Bundle-Version:
> 1.0.0.qualifier Bundle-Name: mhFinPim Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle:
> org.eclipse.core.runtime;bundle-version="3.13.0",
> org.eclipse.swt;bundle-version="3.106.0",
> org.eclipse.e4.core.di;bundle-version="1.6.100",
> org.eclipse.e4.ui.di;bundle-version="1.2.100",
> org.eclipse.e4.core.di.extensions;bundle-version="0.15.0",
> org.eclipse.e4.ui.workbench;bundle-version="1.5.0",
> DatabaseH2;bundle-version="1.0.0"
新的H2数据库插件MANIFEST.MF是这个:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: DatabaseH2
Bundle-SymbolicName: DatabaseH2
Bundle-Version: 1.0.0
Bundle-ClassPath: h2-1.4.196.jar
Export-Package: org.h2,
org.h2.api,
org.h2.bnf,
org.h2.bnf.context,
org.h2.command,
org.h2.command.ddl,
org.h2.command.dml,
org.h2.compress,
org.h2.constraint,
org.h2.engine,
org.h2.expression,
org.h2.fulltext,
org.h2.index,
org.h2.jdbc,
org.h2.jdbcx,
org.h2.jmx,
org.h2.message,
org.h2.mvstore,
org.h2.mvstore.cache,
org.h2.mvstore.db,
org.h2.mvstore.rtree,
org.h2.mvstore.type,
org.h2.result,
org.h2.schema,
org.h2.security,
org.h2.server,
org.h2.server.pg,
org.h2.server.web,
org.h2.store,
org.h2.store.fs,
org.h2.table,
org.h2.tools,
org.h2.upgrade,
org.h2.util,
org.h2.value
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
完成所有这些步骤后,我启动了我的原始插件以查看它是否有效以及该插件是否可以与数据库一起使用。起初我从 eclipse 和下面的堆栈跟踪中收到这条消息:
!SESSION 2017-08-14 09:18:56.882 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_101
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments: -product mhFinPim.prod -clearPersistedState
Command-line arguments: -product mhFinPim.prod -data C:\Users\te_gza2g3_01\workspace/../runtime-ProdConf.product(1) -dev file:C:/Users/te_gza2g3_01/workspace/.metadata/.plugins/org.eclipse.pde.core/ProdConf.product (1)/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -clearPersistedState
!ENTRY org.eclipse.equinox.app 0 0 2017-08-14 09:18:58.547
!MESSAGE Product mhFinPim.prod could not be found.
!ENTRY mhFinPim 2 0 2017-08-14 09:18:58.663
!MESSAGE Could not resolve module: mhFinPim [5]
Unresolved requirement: Require-Bundle: DatabaseH2; bundle-version="1.0.0"
!ENTRY org.eclipse.osgi 4 0 2017-08-14 09:18:58.665
!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:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
gogo: IllegalStateException: session is closed
java.lang.IllegalStateException: session is closed
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:81)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
at java.lang.Thread.run(Thread.java:745)
在将新插件与数据库一起使用之前,应用程序启动时没有任何问题。如果我删除数据库插件,启动再次没有问题。所以,我想知道为什么 eclipse 现在告诉我,没有找到应用程序 ID,为什么找不到插件?!我是否必须添加任何内容来告诉 Eclipse,它可以在哪里找到插件?还是我弄乱了其他东西?
顺便说一句,为了提供完整的信息,这里是 plugin.xml 和产品配置:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="prod"
point="org.eclipse.core.runtime.products">
<product
application="org.eclipse.e4.ui.workbench.swt.E4Application"
name="FinPim">
<property
name="appName"
value="FinPim">
</property>
<property
name="lifeCycleURI"
value="bundleclass://mhFinPim/de.mho.finpim.lifecycle.Manager">
</property>
</product>
</extension>
</plugin>
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="FinPim" uid="ProdConf" id="mhFinPim.prod" application="org.eclipse.e4.ui.workbench.swt.E4Application" useFeatures="true" includeLaunchers="true">
<configIni use="default">
</configIni>
<launcherArgs>
<programArgs>-clearPersistedState
</programArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
</launcherArgs>
<launcher>
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
</vm>
<plugins>
</plugins>
<features>
<feature id="fpFeature"/>
<feature id="org.eclipse.e4.rcp"/>
<feature id="org.eclipse.emf.ecore"/>
<feature id="org.eclipse.emf.common"/>
</features>
<configurations>
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>
</product>
您必须将 DatabaseH2
插件包含在产品包含的插件列表中。
由于您使用的是基于功能的产品,因此您应该在您的功能中列出它 fpFeature
。在fpFeature
中打开feature.xml
并添加DatabaseH2
插件。