I'm developing a multi-tenant Java EE 6 application (where
tenants share a single table) with container
managed @PersistenceContext injection. I keep getting the
Exception [EclipseLink-6174] (Eclipse Persistence Services
Exception Description: No value was provided for the
session property [eclipselink.tenant-id]. This exception is
possible when using additional criteria or tenant
discriminator columns without specifying the associated
contextual property. These properties must be set through
Entity Manager, Entity Manager Factory or persistence unit
properties. If using native EclipseLink, these properties
should be set directly on the session.
I set the multi tenant property for every transaction as
where em is the EntityManager. I get the above exception,
although I set the property. I also debugged the code to make
sure that the property is set (through em.getProperties()),
and I was able to see that it's set. When I reload the page
(i.e. start another transaction), it works.
How can I prevent this exception?