javajava-ee-6cdijboss-weldseam-conversation

@PostConstruct called multiple time for @ConversationScoped bean


I have a @ConversationScoped bean, with a start method, like so:

@PostConstruct
public void start() {
    if (conversation.isTransient()) {
        conversation.begin();
        log.debug("conversation.getId(): " + conversation.getId());
    }
}

My problem is that every time the page is refreshed a new conversation is started, a new conversation is also started every time I have an AJAX call to a method in the bean (which is my main problem).

What I really want to happen is for the sam conversation to hang around until I manually call conversation.end(). What am I missing here?


Solution

  • Did you checked that the (AJAX) calls include the conversation ID parameter (cid)?

    If that's missing, a new conversation is expected to start for each call.