Datanucleus, JDO and executable jar - how to do it?

前端 未结 4 1625
你的背包
你的背包 2020-12-06 07:56

I am developing a desktop app with Datanucleus and JDO for embedded H2 database. It all works fine when I run it from Eclipse, but it stops working when I try to make execut

4条回答
  •  情深已故
    2020-12-06 08:28

    In order to use DataNucleus 4.x in an Apache Storm topology which requires a single jar, I had to do two hacks in order to keep their PluginRegistry stuff working. The issue is that the DataNucleus core tries to load modules as OSGi bundles, even when it is not running in an OSGi container. This works fine as long as the jars are not merged (and I would prefer not to merge my dependencies, but this is not an option for me).

    First, I merged all the plugin.xml files into the datanucleus-core plugin.xml. The trick is that extension-point ids are relative to their parent plugin's id. So if any of the modules your are using define new extension-points, e.g. datanucleus-rdbms, you have to rewrite the ids so they are relative to their new parent plugin.

    Second, I added the following entries to our jar's MANIFEST.MF:

    Premain-Class: org.datanucleus.enhancer.DataNucleusClassFileTransformer
    Bundle-SymbolicName: org.datanucleus;singleton:=true
    

    This solution is not ideal as our application is essentially pretending to be the DataNucleus core OSGi bundle. However, this was what I ended up with after a few days off smashing my head on my desk.

    It might be possible to provide a different PluginRegistry implementation, but I have not looked into this.

提交回复
热议问题