1

My sessionBean in one of my classes was not working fine it was acting as a request bean, I was trying to debug and suspect every part of my xhtml page till the moment i found that I imported the session bean from:

javax.enterprise.context.SessionScoped

instead of:

 javax.faces.bean.SessionScoped;

does this make difference? I mean the bean won't function unless it's imported from javax.faces.bean ?

Thanks,

nx ia
  • 11
  • 1
  • You need to have CDI enabled for that to work. – Bhesh Gurung Jun 01 '18 at 22:19
  • Found this answer here: https://stackoverflow.com/a/15058240/738746 – Bhesh Gurung Jun 01 '18 at 22:30
  • so they are totally different and changing it to javax.faces.bean.SessionScoped; will solve the issue? I'm working on JSF and hibernate and this class i'm having the annotation @SessionScoped in is a bean, a managed bean – nx ia Jun 01 '18 at 22:34
  • Yes, one is from CDI and the other is from JSF. The JSF annotation is working because JSF support there in your server. But the CDI support is either not there or it's not enabled. Otherwise, the other annotation would also do the job. – Bhesh Gurung Jun 01 '18 at 22:38
  • Better to use CDI ones since in jsf 2.3 the jsf ones are deprecated – Kukeltje Jun 02 '18 at 06:30
  • @BheshGurung: you can mark the question as a duplicate via the close link below the question – Kukeltje Jun 02 '18 at 06:31

0 Answers0