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

> On Dec 20, 2015, at 11:45 AM, Marco DE BOOIJ <[email protected]> wrote:
> 
> Keep it in this question :)
> 
> I created a basic application. It has the same behavior. Every call to the 
> bean does an initialisation. I uploaded it to github. The URL is 
> https://github.com/mdebooy/SessionScoped.
> 
> Op 20-12-15 om 15:56 schreef Marco DE BOOIJ:
>> After a nights sleep I came to the conclusion that it will be hard to have 
>> it tested this way. Too much things involved (database, application that 
>> 'delivers' the texts on the screen). I will se if I can make something 
>> simpler and hope that the problem remains. I then will make a new question 
>> when I am ready.
>> 
>> Op 20-12-15 om 10:58 schreef Romain Manni-Bucau:
>>> probably try to make it a single module to make it easy to test
>>> 
>>> 
>>> Romain Manni-Bucau
>>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>>> <http://rmannibucau.wordpress.com> | Github 
>>> <https://github.com/rmannibucau> |
>>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
>>> <http://www.tomitribe.com>
>>> 
> 

Reply via email to