Hi Romain, thanks, I already guessed something like this. But is there some pattern to avoid this or work around or something I could use to make it work?
Basically it means I may not use any cdi on jpa entities whatsoever and that is quite a constraint :) kind regards Reinis -----Original-Nachricht----- > Von: "Romain Manni-Bucau" <[email protected]> > An: [email protected] > Datum: 15-04-2013 14:09 > Betreff: Re: JPA issue in combo with @SessionScoped > > a conflict between cdi and jpa > > > proxying the jpa entity makes another class created and then the jpa > provider doesn't find back your entity > > *Romain Manni-Bucau* > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>* > *Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau* > *Github: https://github.com/rmannibucau* > > > > 2013/4/15 <[email protected]> > > > Hi, > > I have neither pure JPA nor CDI, nor EJB question, it's more of a mix: > > > > I have following classes (reasonably simplified) > > > > @javax.ejb.Stateless > > public class UserProducer { > > > > @PersistenceContext > > EntityManager entityManager; > > > > //Achtung, it produces a SessionScoped logged in user > > @Produces @SessionScoped @my.own.LoggedIn > > public User produceUser() { > > return entityManager.createQuery(..., User.class).getSingleResult(); > > } > > } > > > > > > @javax.ejb.Stateful > > public class AsyncWorker { > > > > @PersistenceContext > > EntityManager entityManager; > > > > @Asynchronous > > public void invokePersist(User user) { > > schedulerEntityService.persist(user); > > } > > } > > > > @RunWith(org.apache.openejb.junit.ApplicationComposer.class) > > class IntegrationTest { > > @Inject @LoggedIn > > User user; > > > > @Inject > > AsyncWorker asyncWorker; > > > > @Test > > public void testIt() { > > asyncWorker.invokePersist(user); //<- No metadata was found for type > > "class my.own.User_$$_javassist_7". The class does not appear in the list > > of persistent types: [my.own.User, ...]. > > } > > } > > > > The OpenJPA throws an org.apache.openjpa.persistence.ArgumentException No > > metadata was found for type "class my.own.User_$$_javassist_7". The class > > does not appear in the list of persistent types: [my.own.User, ...]. > > FailedObject: my.own.User_$$_javassist_7-1 [java.lang.String] > > > > ONLY IF the producer method produceUser() is annotated as @SessionScoped. > > If I remove annotation, the test case works and User entity is being > > persisted. > > > > Can anyone imagine what it could be about? > > > > thank you for your ideas and kind regards > > Reinis > > > > > > > > > >
