The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

SteveHigham (2) [Avatar] Offline
#1
Hi,

I have been through most of your examples using the stack described in the book. I am now trying to get the same examples working using Karaf 4.0.4 and hibernate. I have tried hibernate versions 4.3.6 and the latest version 5.1. I'm using javax.persistence version 2.0.

Everything works fine until I try to inject an EntityManager using:

@PersistenceContext (unitName="fancyfoods")
EntityManager em;

At this point the persistence bundle gets stuck in GracePeriod and ultimately fails to start. Diagnostics returns

Missing dependencies:
(&(osgi.unit.name=fancyfoods)(objectClass=javax.persistence.EntityManager))

I've looked through the logs (log:display) and all the various config and I can't see the problem. Can you suggest a way forward?

I guess my frustration with OSGi tends to be the challenges that arise debugging issues when components won't load. Of course we all have frustrations with the ubiquitous ClassNotFound exception. But at least the stacktrace tends to give you some clues about what is / is not happening at this point. In OSGi I simply know that something which should be providing an EntityManager isn't. This is not very helpful!

Of course, to some extent this is a characteristic of any service orientated architecture. However I perceive many of the advantages of OSGi being the ability to assist in getting multiple frameworks to play together without the risk of implementation problems due to the "classpath hell" referred to in your book. If the reality is that you need detailed knowledge of the implementation of these frameworks to get them to load, then this ambition is compromised.

I guess this will ultimately be addressed by improved tooling and error reporting. In the meantime, any assistance will be appreciated.

Kind Regards,

Steve