Search code examples
eclipsepluginseclipse-rcpe4

H2 Database in E4 Application not resolvable


I am building an E4 Application and want to use an H2 database as persistence store. And I remembered, that I have to put an external library in a plugin to be able to access it from another pluigin or an rcp application. So, I downloaded the jar from the H2 website and followed the steps as described here: http://www.vogella.com/tutorials/EclipseJarToPlugin/article.html I did the checks,everything looked fine and the I included the new plugin in my original plugin. Afterwards, the MANIFEST.MF of this original plugin looked like this:

> 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"

The MANIFEST.MF of the new plugin for the H2 database is this one:

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

After all these steps I started my original plugin to have a look, if it works and if the plugin will work with the database. At first I received this message from eclipse and the stacktrace below: eclipse message

!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)

Before using the new plugin with the database, the application started witout any problem. If I remove the database plugin, the start is without problems again. So, I wonder why eclipse tells me now, that no application id is found and why the plugin can't be found?! Do I have to add anything to tell eclipse, where it can find the plugin? Or did I muss anything else?

Btw, to give the complete information, here are the plugin.xml and the product configuration:

<?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>

Solution

  • You must include the DatabaseH2 plugin in the list of plugins included in the product.

    Since you are using a feature based product you should list it in your feature fpFeature. Open the feature.xml in fpFeature and add the DatabaseH2 plugin.