1

I am writing a small OSGi application for learning purposes. I sucessfully set up Gemini JPA and the DBAccess Services to use JPA, and it is working fine, as long as i use a persistence.xml to configure my persistence units.

Then i stumbled across This Example. It seems like a really great feature to provide a persistence unit configuration at runtime. Except it is not working. I tried that exact code (for the Standalone Configuration), and it is executed, but nothing changes in the framework. As far as i understand, shouldn't there be a new service providing the new Persistence Unit?

I' am using the Equinox framework, all necessary bundles for gemini and dbaccess are installed and running, and the ConfigurationAdmin bundle (org.eclipse.equinox.cm) is installed and running at the point my code is executed.

I access the Configuration Admin like this:

ServiceReference<ConfigurationAdmin> s = context
            .getServiceReference(ConfigurationAdmin.class);
ConfigurationAdmin admin = context.getService(s);
Simiil
  • 2,281
  • 1
  • 22
  • 32

1 Answers1

0

Maybe a start order problem: the configuration must be created before the data source is looked-up for persistence. Try restarting your persistence bundle or change the start level of the persistence bundle to a higher level so it is started at a later time.

Furthermore, it may be handy to install the Felix web console to see whether your configuration data is indeed registered with the configuration manager.

  • both is correct. I can see the registered config in the webconsole, and i also can not see a new Entitymanager-factory Service for this configuration as described in the question – Simiil Dec 02 '13 at 12:44
  • Maybe you should post some more detail about the exact set-up and the properties you set. I think you still need to tell the JPA implementation that the bundle needs to be set-up for exporting an EMF since that is what you are currently seem to be missing. – Arie van Wijngaarden Dec 02 '13 at 13:23
  • Yes i think this may be the case, but i dont know how to do that. The turotial clearly states `...a standalone configuration is used only when there is no persistence descriptor in the persistence bundle` – Simiil Dec 02 '13 at 17:52
  • According to the document you referred to, you must specify the `gemini.jpa.punit.bsn` property. Did you do that correctly? That is the only obvious reason I see why the JPA implementation did ignore the bundle completely. – Arie van Wijngaarden Dec 02 '13 at 19:33