Announcement Announcement Module
No announcement yet.
Spring Webflow integration with Spring MongoDB issues Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Webflow integration with Spring MongoDB issues

    Hi, I wrote a custom ConversationManager having a Repository object using a MongoTemplate. I am getting a NullPointerException when storing the FlowExecution object, the reason is 'messagesMemento' contains LinkedHashMap entry containing a null key ({null=[]}). The exception is thrown when SpringMongo tries to call getClass() on that null key. It makes no sense to store a null key entry for one side and for another, I don't know if having such entry has some use.

    The only solution I found for now is to skip storing flash scope objects (since fortunately I don't use flash scope) by rewriting FlowExecutionImpl and commenting out the code inside "saveFlashMessages(RequestContext)" and guarding for null in getFlashScope() in method "createMessageContext(MessageSource)" which is highly discouraged.

    Here is a link to the post I wrote in the SpringMongo forum:

    I am using SpringWebflow 2.3.0.RELEASE and SpringMongo 1.0.0.RELEASE.

    Last edited by marcovmx; Feb 14th, 2012, 05:23 PM.

  • #2
    I expected to have an answer to this thread from any of the spring web flow team members, since I considered this issue to be sensitive because it makes two of the spring modules incompatible and not possible to integrate. How could (spring) mongodb could actually store a null key entry coming from a spring web flow object?


    • #3
      the reason is 'messagesMemento' contains LinkedHashMap entry containing a null key ({null=[]})
      Could you provide a bit more detail on how this comes about?


      • #4
        Thanks for responding Rossen,

        Well, I have a Spring Webflow configuration with a custom conversation manager using a custom conversation reopository to store conversations with spring mongo db.

        class CustomConversation implements Conversation {
        	public void unlock() {
        		if (lockCount == 0) {
        			if (!ended) {
        public class CustomConversationRepository implements ConversationRepository {
        	public void saveConversation(Conversation conversation) {
        		logger.debug("Saving conversation: " + conversation);
        I didn't do anything else in special, just storing the conversations (I did not manipulate Flow Execution objects). I get a NPE when I start the flow. Digging into the source code I realized of the symptom described above. The 'messagesMemento' object gets created all by the Spring Web Flow framework, and at some point it stores an entry in its map containing a null key, and that is not possible to be stored in mongodb.

        I hope that explains better.



        • #5
          hey Marco,

          did you find a solution? Do you mind sharing your code. I'm very curious how you implemented the Mongo Conversation Abstraction.



          • #6
            I did the same! I am running into the same issue now. On the post you referenced, you mentioned using the ConversationManager as a way to get rid of this NPE? How did you do that?

            Or did you end up having to create a FlowExecutionImpl? I didn't think it was possible in SWF v 2.3 to inject these anymore like before how did you inject a custom one?

            I'm thinking of just checking for this messagesMem field and if null just remove it before i save. I want to use flashscope evenutally.

            Could you post more on what you found out as it seems I'm attempting to do the same please?


            • #7
              First, I recommend to use the most updated spring mongodb and webflow. If you still have that horrible issue, then what I suggest to do is to get the flash attributes and iterate over them to remove null keys right before saving the conversation. I hope it helps.


              • daisygmiller
                daisygmiller commented
                Editing a comment
                Thank you! Got past this. And for anyone else running into this as of today this is still an issue using the following versions:

                org.springframework.version 3.2.2.RELEASE
                - Used for spring-data-mongodb
                org.springframework.webflow.version 2.3.2.RELEASE
                Last edited by daisygmiller; Nov 7th, 2013, 09:19 AM. Reason: added framework names, they were deleted on post somehow