Simiil
Simiil

Reputation: 2311

OSGi and Gemini JPA: Using the Configuration Admin

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

Upvotes: 1

Views: 578

Answers (1)

Arie van Wijngaarden
Arie van Wijngaarden

Reputation: 1146

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.

Upvotes: 0

Related Questions