-
15. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 12, 2011 5:55 AM (in response to hantsy)I have posted the related codes in the fisrt post of this topic...
I seems the Many to Many relation(lazy by default) caused the problem.
-
16. Re: How to avoid LazyInitializationException in facelets page.
ssachtleben.ssachtleben.gmail.com Sep 12, 2011 7:34 AM (in response to hantsy)Yeah @ManyToMany will be fetch lazy by default and proxied untill you need it. The LazyInitializationException means the entity is detached from entitymanager.
Seems like there are several possible solutions:
@ManyToMany(fetch=FetchType.EAGER)
or
this.currentAddressee = em.find("from " + Addressee.class.getName() + " fetch all properties where id = :0").setParameter(0, this.addresseeId)...
If you use Seam Managed Persistence and the conversation is properly set then it seems like a bug. The entity shouldn't be detached, or am I wrong?
-
17. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 12, 2011 8:09 AM (in response to hantsy)I think this is a bug... the code was migrated from the before seam2 application.
I used some pages like this in before Seam 2 applications, I had not encountered such problems.
-
18. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 12, 2011 8:51 AM (in response to hantsy)I filed a bug about this...
-
19. Re: How to avoid LazyInitializationException in facelets page.
lightguard Sep 12, 2011 10:26 PM (in response to hantsy)Hantsy, you're using it wrong.
You're already inside of a Stateful Session bean, which wraps all of the method calls on that bean inside of a transaction. Because you're also using Seam Faces, it also wraps the request in a transaction. Then yet again, you're save method is starting a transaction. It's no wonder you're having problems with transactions already being active. This would have been a problem in Seam 2 as well. Pick a strategy and stick with it, and only that one, you'll save yourself many headaches such as this one.
Also, when you say you created a bug, please post a link to the bug you created so others can follow it.
-
20. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 12, 2011 10:55 PM (in response to hantsy)By default, the transaction should use REQUIRED propagation , it will use the existed transaction or create a new one(if it is not existed), right ?
So, I do not think if transaction is added or not caused the problem.
-
21. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 13, 2011 4:05 AM (in response to hantsy)Yes, I filed a bug about this.
Now I am working on a large Seam 2 project over one year, I never encountered such problems.
Some of these codes are migrated from the Seam 2 project, the logic of the code is not change, only changed the api.
The problem here is there is no active session found in the Conversation scope, it is so strange?
-
22. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 13, 2011 4:13 AM (in response to hantsy)The seam managed persistence should make the entity manager active in the whole conversation scope, some like using EntityManagerType.EXTENDED in a stateful session bean...
But obviously, I used Seam managed persistence, but it did not provide such a feature.
-
23. Re: How to avoid LazyInitializationException in facelets page.
ssachtleben.ssachtleben.gmail.com Sep 13, 2011 4:25 AM (in response to hantsy)hantsy please post the link if you file a jira issue like Jason mentioned.
btw why do you need @Stateful?
-
24. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 13, 2011 5:12 AM (in response to hantsy)I had added the link in the
Forum Reference
field.OK, I added another link in the comments.
-
25. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 13, 2011 5:20 AM (in response to hantsy)There is no requirement I must use @Stateful session bean, I only wanted to try the EJB 3.1 none interface bean, there is no difference from POJO in programming view. I know it will be managed by the EJB container at runtime.
-
26. Re: How to avoid LazyInitializationException in facelets page.
ssachtleben.ssachtleben.gmail.com Sep 13, 2011 5:22 AM (in response to hantsy)I think we miss understood. If you add a jira issue you should post the link in the depending forum thread (like I did for you).
The forum reference in the jira issue is fine. Everything is ok. :)Due the f2f meeting in Toronto this week, I should expect much response this week.
-
27. Re: How to avoid LazyInitializationException in facelets page.
ssachtleben.ssachtleben.gmail.com Sep 13, 2011 5:25 AM (in response to hantsy)Sorry I mean:
I wouldn't expect much response this week
-
28. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 13, 2011 5:27 AM (in response to hantsy)Oh, I understand now.
Thanks -
29. Re: How to avoid LazyInitializationException in facelets page.
hantsy Sep 16, 2011 6:32 AM (in response to hantsy)I have tried ur propsals,
1. use pojo instead of EJB
or
2. remove @TransactionalAnd the same exception in the saved method