Write a servlet called StartConversationServlet that injects a CDI Conversation object, and that calls conversation.begin() in #doGet, then shows the id of the just created conversation.
Write another servlet called ViewConversationServlet that injects a ConversationScoped object and that prints out conversation.getId() in #doGet (and does something with the injected ConversationScoped object).
Deploy the two servlets and the ConversationScoped object in a war.
Query the StartConversationServlet first. Several times. It always tells you that it has created a conversation with id 1. (Expected: a conversion with a different id on every call.) Relatedly, when you query ViewConversationServlet with ?cid=1, weld tells you:
org.jboss.weld.context.NonexistentConversationException: WELD-000321: No conversation found to restore for id 1
. (Expected: the conversation exists.)
Query ViewConversationServlet with no ?cid parameter. Then everything starts to work as it should. Expectedly, ViewConversationServlet tells you that the current conversation id is “null”. Then, querying StartConversationServlet expectedly starts a conversation with id 1, then 2, and so on. Now, querying ViewConversationServlet with ?cid=1 does not fail any more.
The same happens when setting a timeout to 10_000 milliseconds in StartConversationServlet for the conversation.
The sample code is in GitHub.