Announcement Announcement Module
Collapse
No announcement yet.
JDBC Inbound Adapter fails on update with exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JDBC Inbound Adapter fails on update with exception

    I am using Spring version 3.0.5 with Integration version 2.0.3 (I have also tried with 2.0.5 and received the same exception). I am doing the local development work on a Windows 7 machine with Java 1.6.0_11 installed. I am seeing the exception on a testing host that I use that is running RHEL 5.6 with Java 1.6.0_16 installed.

    The software is basically pulling some records from a database, doing some basic processing on them, and pushing them out to a JMS destination.

    My configuration is something like this:

    Code:
    	<int-jdbc:inbound-channel-adapter id="readDatabaseResults"
    	                                  channel="databaseResults"
    	                                  data-source="datasource"
    	                                  row-mapper="dataResultRowMapper"
    	                                  max-rows-per-poll="50"
    	                                  query="select record_id, record_date, record_value from my_table where completed is null"
    	                                  update="update my_table set completed = sysdate where record_id = :recordId and record_date = :recordDate"
    	                                  update-per-row="true">
    		<poller fixed-rate="5000">
    			<transactional/>
    		</poller>
    	</int-jdbc:inbound-channel-adapter>
    	
    	<channel id="databaseResults"/>
    	
    	<splitter id="splitResults" 
    			  input-channel="databaseResults" 
    			  output-channel="individualDatabaseResults"
    			  expression="payload"/>
    			  
    	<channel id="individualDatabaseResults"/>
    	
    	<service-activator id="databaseResultProcessor"
    					   input-channel="individualDatabaseResults"
    					   output-channel="processedDatabaseResults"
    					   ref="springResultProcessor" 
    					   method="processResultRecords"/>
    					   
    	<channel id="processedResults"/>
    	
    	<transformer id="resultToMessageTransformer"
    				 ref="resultTransformer"
    				 method="transformResult"
    				 input-channel="processedResults"
    				 output-channel="processedResultMessages"/>
    	
    	<channel id="processedResultMessages"/>
    	
    	<int-jms:outbound-channel-adapter id="resultMessageQueue"
    						         channel="processedResultMessages"
    						         connection-factory="jmsConnectionFactory"
                                                             destination="resultDestination"
    					                 message-converter="myMessageConverter"/>
    After some time (approximately 900-1000 records, though this number seems to vary making it even harder to track down this problem it seems), I receive the following exception, which appears to be coming from the parameter mapping during the update attempt after reading and mapping the results to my data type. Once this failure occurs, it will re-occur with every poll going forward. It is a pair of exceptions so I will seperate the log lines for readability (see next post)

    This problem only seems to occur on the RHEL host as I have not been able to reproduce it yet on my Windows machine. I have also tried verifying that it is not an issue with the record by having it process the record it failed on alone. It also seems to have no issue processing the record it failed on later after I restart the process.

  • #2
    The Exceptions:

    Code:
    [2011-08-02 08:53:52,172][DEBUG][taskScheduler-33][channel.PublishSubscribeChannel][preSend on channel 'errorChannel', message: [Payload=java.lang.ClassCastException: my.datatype.Class cannot be cast to java.util.Map][Headers={timestamp=1312293232172, id=a8b2144b-6507-4595-a2b8-081ce7fc1303, history=errorChannel}]]
    [2011-08-02 08:53:52,172][DEBUG][taskScheduler-33][handler.LoggingHandler][(inner bean)#4 received message: [Payload=java.lang.ClassCastException: my.datatype.Class cannot be cast to java.util.Map][Headers={timestamp=1312293232172, id=a8b2144b-6507-4595-a2b8-081ce7fc1303, history=errorChannel}]]
    [2011-08-02 08:53:52,173][WARN][taskScheduler-33][channel.MessagePublishingErrorHandler][Error message was not delivered.]
    org.springframework.integration.MessageHandlingException: error occurred in message handler [(inner bean)#4]
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:84)
            at org.springframework.integration.dispatcher.BroadcastingDispatcher.invokeHandler(BroadcastingDispatcher.java:105)
            at org.springframework.integration.dispatcher.BroadcastingDispatcher.dispatch(BroadcastingDispatcher.java:96)
            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.MessagePublishingErrorHandler.handleError(MessagePublishingErrorHandler.java:83)
            at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
            at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
            at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:201)
            at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:51)
            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:207)
            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:619)
    Caused by: java.lang.ClassCastException: org.springframework.integration.message.ErrorMessage 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.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
            at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:93)
            at org.springframework.integration.handler.LoggingHandler.handleMessageInternal(LoggingHandler.java:90)
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
            ... 19 more
    Followed by:

    Code:
    [2011-08-02 08:53:26,170][ERROR][taskScheduler-14][channel.MessagePublishingErrorHandler][failure occurred in messaging task]
    java.lang.ClassCastException: my.datatype.Class 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.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.jdbc.ExpressionEvaluatingSqlParameterSourceFactory.access$100(ExpressionEvaluatingSqlParameterSourceFactory.java:36)
            at org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory$ExpressionEvaluatingSqlParameterSource.getValue(ExpressionEvaluatingSqlParameterSourceFactory.java:133)
            at org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory$ExpressionEvaluatingSqlParameterSource.hasValue(ExpressionEvaluatingSqlParameterSourceFactory.java:143)
            at org.springframework.jdbc.core.namedparam.NamedParameterUtils.substituteNamedParameters(NamedParameterUtils.java:203)
            at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.getPreparedStatementCreator(NamedParameterJdbcTemplate.java:314)
            at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:259)
            at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.update(SimpleJdbcTemplate.java:243)
            at org.springframework.integration.jdbc.JdbcPollingChannelAdapter.executeUpdateQuery(JdbcPollingChannelAdapter.java:166)
            at org.springframework.integration.jdbc.JdbcPollingChannelAdapter.poll(JdbcPollingChannelAdapter.java:154)
            at org.springframework.integration.jdbc.JdbcPollingChannelAdapter.receive(JdbcPollingChannelAdapter.java:134)
            at org.springframework.integration.endpoint.SourcePollingChannelAdapter.doPoll(SourcePollingChannelAdapter.java:89)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:145)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:143)
            at sun.reflect.GeneratedMethodAccessor3.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:309)
            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.invoke(TransactionInterceptor.java:110)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
            at $Proxy6.call(Unknown Source)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:206)
            at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
            at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
            at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:201)
            at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:51)
            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:207)
            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:619)

    Comment


    • #3
      THis has actually been reported but the issue seems to be in JDK - http://forum.springsource.org/showth...sCastException.

      In fact in that thread I am attaching the test cases that I used to debug this issue few years ago. Unfortunately we can not find any reported bug against it nor can it be reproduced in the newer JVMs, so I would suggest to get the lates 1.6

      Comment


      • #4
        Thank you for the information. I had a suspicion the issue might be related to JDK/OS since that is the only real difference between my local execution and the one on the other host. I will see if that bug example shows anything and look into if I can have the JDK changed there.

        Comment

        Working...
        X