Announcement Announcement Module
Collapse
No announcement yet.
JdbcChannelMessageStore throwing SerializationFailedException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JdbcChannelMessageStore throwing SerializationFailedException

    Hi,

    In our production server, we are getting the following exception logged multiple times.

    Code:
    [org.springframework.integration.handler.LoggingHandler] ERROR - org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.EOFException
    	at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:61)
    	at org.springframework.integration.jdbc.store.channel.MessageRowMapper.mapRow(MessageRowMapper.java:43)
    	at org.springframework.integration.jdbc.store.channel.MessageRowMapper.mapRow(MessageRowMapper.java:32)
    	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
    	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
    	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:651)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:639)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:664)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:704)
    	at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:179)
    	at org.springframework.integration.jdbc.store.JdbcChannelMessageStore.doPollForMessage(JdbcChannelMessageStore.java:456)
    	at org.springframework.integration.jdbc.store.JdbcChannelMessageStore.pollMessageFromGroup(JdbcChannelMessageStore.java:568)
    	at org.springframework.integration.store.MessageGroupQueue.doPoll(MessageGroupQueue.java:278)
    	at org.springframework.integration.store.MessageGroupQueue.poll(MessageGroupQueue.java:130)
    	at org.springframework.integration.store.MessageGroupQueue.poll(MessageGroupQueue.java:47)
    	at org.springframework.integration.channel.QueueChannel.doReceive(QueueChannel.java:91)
    	at org.springframework.integration.channel.AbstractPollableChannel.receive(AbstractPollableChannel.java:57)
    	at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	at org.springframework.integration.monitor.PollableChannelMetrics.monitorReceive(PollableChannelMetrics.java:55)
    	at org.springframework.integration.monitor.PollableChannelMetrics.doInvoke(PollableChannelMetrics.java:45)
    	at org.springframework.integration.monitor.DirectChannelMetrics.invoke(DirectChannelMetrics.java:91)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy170.receive(Unknown Source)
    	at org.springframework.integration.endpoint.PollingConsumer.receiveMessage(PollingConsumer.java:79)
    	at org.springframework.integration.endpoint.AbstractTransactionSynchronizingPollingEndpoint.doPoll(AbstractTransactionSynchronizingPollingEndpoint.java:67)
    	at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
    	at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:144)
    	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
    	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy172.call(Unknown Source)
    	at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:236)
    	at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
    	at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:231)
    	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)
    	at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:662)
    Caused by: java.io.EOFException
    	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
    	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
    	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
    	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
    	at org.springframework.core.serializer.DefaultDeserializer.deserialize(DefaultDeserializer.java:38)
    	at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:58)
    	... 60 more

    We inspected the <prefix>_CHANNEL_MESSAGE table that the channel message store is using and found out that it contains records with blobs having zero bytes. (We're using Oracle DB btw). As I understand, the only thing that writes to this table is Spring Integration channel message store and there's no way it can have records with empty blobs in it as we're passing GenericMessage objects to the channel.

    This issue doesn't seems to be affecting valid message rows and they seemed to be consumed properly. Only the ones that have empty blobs just keep hanging there and every time the poller queries the DB, the exceptions are getting logged.

    We are using Spring Integration 2.2.2.RELEASE version.

    Have any of you experienced this kind of issue in your environments? Any solution is highly appreciated.

    Thanks.

  • #2
    Hi!

    Can you show your JdbcChannelMessageStore configuration?

    BTW, it should be something like this:
    HTML Code:
    <bean id="channelMessageStore" class="org.springframework.integration.jdbc.store.JdbcChannelMessageStore"
    	  p:dataSource-ref="dataSource" p:tablePrefix="SI_" p:deserializer-ref="simpleDeserializer">
    	<property name="channelMessageStoreQueryProvider">
    		<bean class="org.springframework.integration.jdbc.store.channel.OracleChannelMessageStoreQueryProvider"/>
    	</property>
    </bean>
    Where simpleDeserializer like this:
    Code:
    @Component
    class SimpleDeserializer implements Deserializer {
    
    	Object deserialize(InputStream inputStream) {
    		new ConfigurableObjectInputStream(inputStream, ClassUtils.defaultClassLoader).readObject()
    	}
    
    }
    To avoid ClassNotFoundException in the parent-child ClassLoaders.

    I don't recommend to use OracleLobHandler it is Deprecated since Spring 3.2.

    Cheers,
    Artem

    Comment


    • #3
      Artem,

      Here's my config:

      Code:
          <bean id="oracleChannelMessageStoreQueryProvider" class="org.springframework.integration.jdbc.store.channel.OracleChannelMessageStoreQueryProvider" />
      
          <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor" />
      
          <bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
              <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor" />
          </bean>
          
          <bean id="channelMessageStore" class="org.springframework.integration.jdbc.store.JdbcChannelMessageStore">
              <property name="dataSource" ref="myDataSource"/>
              <property name="channelMessageStoreQueryProvider" ref="oracleChannelMessageStoreQueryProvider"/>
              <property name="lobHandler" ref="lobHandler"/>
          </bean>

      Do I have to care about the de-serializer at all?

      Cheers.

      Comment


      • #4
        Your problem here:
        it contains records with blobs having zero bytes.
        And I said you do not to use OracleLobHandler.
        I can guess, that OracleLobHandler doesn't provide bytes correctly to the driver, so that's why you don't have anything in the BLOB field in the DB.

        Which version of Oracle do you use and which oracle driver?

        Comment


        • #5
          Hi,

          Oracle DB version : 10.2
          Oracle JDBC Driver version: 11.2.0.1.0

          I agree that we can switch to DefaultLobHandler since we're using Oracle DB 10.2.

          Cheers.

          Comment


          • #6
            Has this problem been fixed? I'm experiencing the same issue.

            Code:
            [Payload=org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for SimpleDeserializer?; nested exception is java.io.StreamCorruptedException: invalid stream header: 5C786163][Headers={timestamp=1371243721289, id=9373d6e4-10d2-49d4-bde4-5ccf68db03b0, history=errorChannel,errorChannelLogger}]
            My deserializer is written as follows:
            Code:
            public class SimpleDeserializer implements Deserializer {
            
                @Override
                public Object deserialize(InputStream inputStream) throws IOException {
                    try {
                        return new ConfigurableObjectInputStream(inputStream, ClassUtils.getDefaultClassLoader()).readObject();
                    }
                    catch (ClassNotFoundException e) {
                        // TODO Auto-generated catch block
                        return e;
                    }
                }
            }
            I have my project configured as follows:
            Code:
              	<beans:bean id="messageStoreData" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
              		<beans:property name="driverClassName" value="org.postgresql.Driver" />
            		<beans:property name="url" value="jdbc:postgresql://localhost:5432/messageStore" />
            		<beans:property name="username" value="doss" />
            		<beans:property name="password" value="password" />
              	</beans:bean>
              	
              	<beans:bean id="messageStore" class="org.springframework.integration.jdbc.store.JdbcChannelMessageStore">
              		<beans:property name="dataSource" ref="messageStoreData"/>
              		<beans:property name="deserializer" ref="simpleDeserializer"/>
              		<beans:property name="channelMessageStoreQueryProvider" ref="postgresChannelMessageStoreQueryProvider"/>
              		
              	</beans:bean>
              	
              	<beans:bean id="postgresChannelMessageStoreQueryProvider" class="org.springframework.integration.jdbc.store.channel.PostgresChannelMessageStoreQueryProvider" />
            I have traced the problem in the debugger to the ObjectInputStream class' readStreamHeader function, but cannot figure out why the version number and magic number are failing.
            Code:
                protected void readStreamHeader()
            	throws IOException, StreamCorruptedException
                {
            	short s0 = bin.readShort();
            	short s1 = bin.readShort();
            	if (s0 != STREAM_MAGIC || s1 != STREAM_VERSION) {
            	    throw new StreamCorruptedException(
            		String.format("invalid stream header: %04X%04X", s0, s1));
            	}
                }
            Any ideas?

            Thanks,
            K

            PS.

            If it helps, here is how my tables are defined:
            Code:
                        Table "public.int_message_group"
                     Column         |       Type        | Modifiers 
            ------------------------+-------------------+-----------
             message_id             | character varying | 
             group_key              | character varying | 
             region                 | character varying | 
             marked                 | character varying | 
             complete               | character varying | 
             last_released_sequence | character varying | 
             created_date           | character varying | 
             updated_date           | character varying | 
            
              Table "public.int_message"
                Column     |       Type        | Modifiers 
            ---------------+-------------------+-----------
             message_id    | character varying | 
             region        | character varying | 
             created_date  | character varying | 
             message_bytes | character varying | 
            
             Table "public.int_group_to_message"
               Column   |       Type        | Modifiers 
            ------------+-------------------+-----------
             message_id | character varying | 
             group_key  | character varying |
            Last edited by kashiB; Jun 14th, 2013, 05:18 PM.

            Comment


            • #7
              I fixed it. My schema was wrong. I didn't see the schema files located in the JDBC jar.

              Comment


              • #8
                Originally posted by kashiB View Post
                Has this problem been fixed? I'm experiencing the same issue.
                I have changed my lobHandler from OracleLobHandler to DefaultLobHandler and deployed. It's just a couple of days and I'm still keeping an eye on for any zero byte Blobs but so far none have occurred. Fingers crossed.

                Cheers,

                -P

                Comment

                Working...
                X