Announcement Announcement Module
Collapse
No announcement yet.
GenericMessage cannot be cast to java.util.Map Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • GenericMessage cannot be cast to java.util.Map

    I've written a simple SI flow that accepts requests via AMQP (Rabbit), and based on the contents of the message, generates a PDF report and delivers it to one of several potential endpoints (all sftp). When processing a relatively small number of reports (~1250, but not consistently the same number), I will end up with the following exception. Restarting the container hosting my SI app (in this case, Tomcat), fixes the issue - the messages in the queue that were previously unack'd due to errors are processed without any problems. Once this exception crops up, every message fails, regardless of the contents. Has anyone run into a similar problem? Sorry for the enormous stacktrace, it looks like the really interesting parts (e.g., the cast exception) are at the bottom, but I wanted to include the entire thing for completeness.
    Code:
    org.springframework.amqp.rabbit.listener.ListenerExecutionFailedException: Listener threw exception
    	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:704)
    	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:546)
    	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:489)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$001(SimpleMessageListenerContainer.java:52)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$1.invokeListener(SimpleMessageListenerContainer.java:97)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:543)
    	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468)
    	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:441)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:426)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:411)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$200(SimpleMessageListenerContainer.java:52)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:488)
    	at java.lang.Thread.run(Thread.java:619)
    Caused by: org.springframework.integration.MessageDeliveryException: Failed to create sendable file.
    	at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.redeemForStorableFile(FileTransferringMessageHandler.java:161)
    	at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:96)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:110)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:44)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
    	at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
    	at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
    	at org.springframework.integration.router.AbstractMessageRouter.handleMessageInternal(AbstractMessageRouter.java:220)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:110)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:44)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
    	at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
    	at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:176)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:160)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:125)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:119)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:101)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:110)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:44)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
    	at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
    	at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:176)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:160)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:125)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:119)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:101)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:110)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:44)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
    	at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
    	at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
    	at org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:92)
    	at org.springframework.integration.amqp.AmqpInboundChannelAdapter.access$100(AmqpInboundChannelAdapter.java:38)
    	at org.springframework.integration.amqp.AmqpInboundChannelAdapter$1.onMessage(AmqpInboundChannelAdapter.java:78)
    	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:544)
    	... 11 more
    Caused by: java.lang.ClassCastException: org.springframework.integration.message.GenericMessage cannot be cast to java.util.Map
    	at org.springframework.context.expression.MapAccessor.canRead(MapAccessor.java:37)
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:189)
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:71)
    	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52)
    	at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
    	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
    	at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:98)
    	at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:94)
    	at org.springframework.integration.file.DefaultFileNameGenerator.generateFileName(DefaultFileNameGenerator.java:64)
    	at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.redeemForStorableFile(FileTransferringMessageHandler.java:143)

  • #2
    Can you please let us know what version of Spring Integration you are using?

    Comment


    • #3
      I am using 2.0.3.RELEASE

      Comment


      • #4
        Thank you, and sorry - should have also asked: what version of Spring?

        -Mark

        Comment


        • #5
          3.0.5.release

          Comment


          • #6
            Are you using MAC OS?

            Comment


            • #7
              I am developing on MacOS, but the error is being observed on CentOS w/ Tomcat 6.0.20 and Sun JRE 1.6.0_18-b07.

              Comment


              • #8
                Going through the memory archives I remembered similar issue from a while back and it ended up to be some bug in JDK. Unfortunately I can't find an official bug report, but based on some of the emails I tracked it down to clazz.isAssignableFrom(targetType) which is a native method.
                I was even able to find an independent test that at the time was able to reproduce it, but unfortunately I am all up to date with JDK so it no longer fails for me. So I am attaching it so may be you'll have a better luck. Don't remember all the details, but there is line of code commented, so play around with uncommenting it etc., but you should see the error.

                Then you can upgrade your JDK and see if it resolves the issue.
                Let us know

                Comment


                • #9
                  Thanks, Oleg. Upgrading the JVM fixes the issue, but I'd like to have a better understanding of the underlying JVM bug; I can't find any references to bugs with the isAssignableFrom method; I found a commented-out test case simliar to the one you provided that was committed in 3313 by Andy Clement (testFails() method). Are there any additional details or documentation links you can provide on the root cause for this problem?

                  Thanks,
                  Will

                  Comment


                  • #10
                    No, unfortunately we went through the same process of trying to find it and could not. And the test from Andy you are looking for is probably the result of our discussion with him last year related to this particular issue. In fact I was talking to him again before replying to you last time asking him if he knows anything more.
                    Anyway, I am glad its working for you
                    Cheers

                    Comment


                    • #11
                      Originally posted by oleg.zhurakousky View Post
                      No, unfortunately we went through the same process of trying to find it and could not. And the test from Andy you are looking for is probably the result of our discussion with him last year related to this particular issue. In fact I was talking to him again before replying to you last time asking him if he knows anything more.
                      Anyway, I am glad its working for you
                      Cheers
                      Fair enough, at least there's a known fix. I usually like to have a deeper understanding of issues like this in case some other unexpected facet of it comes back to bite me later on; in this instance, it seems like I'm going to just have to acknowledge that it appears fixed and move forward. Thank you for all of your help on this issue.

                      Regards,
                      Will

                      Comment


                      • #12
                        Thanks Will. We did spend a lot of time trying to track down more detail, ideally a specific bug record. In the end, all we know is that our tests fail reliably with older versions of the JDK and pass reliably with newer versions. If you happen to find any more detail yourself, please do post it back here.

                        -Mark

                        Comment

                        Working...
                        X