Announcement Announcement Module
Collapse
No announcement yet.
Spring Webflow integration with Spring MongoDB issues Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:
    http://forum.springsource.org/showth...MongoConverter

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

    Thanks,
    Marco
    Last edited by marcovmx; Feb 14th, 2012, 06: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?

    Comment


    • #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?

      Comment


      • #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.

        Code:
        class CustomConversation implements Conversation {
        	...
        	public void unlock() {
        		lock.unlock();
        		lockCount--;
        		if (lockCount == 0) {
        			if (!ended) {
        				repository.saveConversation(this);
        			}
        			CustomConversationHolder.removeConversation(getId());
        		}
        	}
        	...
        Code:
        @Repository
        public class CustomConversationRepository implements ConversationRepository {
        	...
        
        	
        	public void saveConversation(Conversation conversation) {
        		logger.debug("Saving conversation: " + conversation);
        		mongoTemplate.save(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.

        Thanks,
        Marco

        Comment


        • #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.

          best
          tobias

          Comment


          • #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?

            Comment


            • #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.

              Comment


              • 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
                org.springframework.data.version 1.3.1.RELEASE
                - Used for spring-data-mongodb
                org.springframework.webflow.version 2.3.2.RELEASE
                Last edited by daisygmiller; Nov 7th, 2013, 10:19 AM. Reason: added framework names, they were deleted on post somehow
            Working...
            X