Thank you Greg for your explanation. With the hint of Romain I found this just before I read your mail. I think that there is even a third SessionScoped class.

Op 20-12-15 om 22:44 schreef Greg Trasuk:
Marco:

There are two different @SessionScoped annotations in the JEE6 API - 
‘javax.faces.bean.SessionScoped’ (this is from the JSF spec) and 
‘javax.enterprise.context.SessionScoped’ (this is from the CDI spec).  When you 
created a JSF managed bean, you need to be consistent - if you use the 
@ManagedBean annotation, then you can use the jsf @SessionScoped annotation, 
but if you use the @Named annotation, then you need to use the CDI spec 
annotation.

Unfortunately, Eclipse doesn’t know this, so if you used ‘Ctrl-Shift-O’ to 
organize your imports, and you’re not paying attention to which one it picks, 
you can end up importing the wrong annotation very easily.

Change the ‘import’ statement in your ‘Tomee.java’ to import 
javax.enterprise.context.SessionScoped rather than 
javax.faces.beans.SessionScoped and your bean should work as you intend.

Cheers,

Greg Trasuk
http://www.webagesolutions.com


Reply via email to