Reputation: 11
Like I say in the title, I have a method with the @PostConstruct
tag in a managed bean in session scope. But the method is never called. In another bean in view scope the @PostConstruct
works fine.
The @Postconstruct
tag work in a session bean?
That's basically my question.
Bye and thanks!
Upvotes: 0
Views: 2934
Reputation: 11
I was also facing the same issue. The issue get resolved when I destroy the bean from the session(if the bean is in the session scope, it works fine for request scope). When the bean is in the session scope, the method with the @PostConstruct annotation will never be called twice, as the bean has already been instantiated and is stored in the session.
Upvotes: 1
Reputation: 1108722
Also, the constructor is never called, but the bean work just fine, except the @postconstruct method and constructor not called
Either you have not compiled and deployed the bean class with the changes, or you have another copy of the bean with the same name but in a different package which in turn is actually been used instead.
Verify everything, cleanup everything and do a full rebuild/redeploy/restart.
Upvotes: 0
Reputation: 81
Make sure you don't have a @PostConstruct on any other method in your bean or your bean's predecessor. There is only one @PostConstruct allowed for a managed bean.
Upvotes: 1
Reputation: 944
How do you refer the session bean? Maybe the bean was not instantiated yet, do you also have some logging in the constructor of the managed bean?
Upvotes: 0