异常信息如下:

org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.util.Date] to required type [java.sql.Timestamp] for property 'wfsj': no matching editors or conversion strategy found

    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:463)

    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:494)

    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1097)

    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:882)

    at org.springframework.flex.core.io.SpringPropertyProxy.setValue(SpringPropertyProxy.java:182)

    at flex.messaging.io.amf.Amf3Input.readScriptObject(Amf3Input.java:438)

    at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:152)

    at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:130)

    at flex.messaging.io.amf.Amf3Input.readArray(Amf3Input.java:358)

    …………

    at flex.messaging.io.amf.AmfMessageDeserializer.readObject(AmfMessageDeserializer.java:227)

    at flex.messaging.io.amf.AmfMessageDeserializer.readBody(AmfMessageDeserializer.java:206)

    at flex.messaging.io.amf.AmfMessageDeserializer.readMessage(AmfMessageDeserializer.java:126)

    at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:145)

    at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291)

    at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$6f090fa2.service(<generated>)

    at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:109)

    …………

Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.util.Date] to required type [java.sql.Timestamp] for property 'wfsj': no matching editors or conversion strategy found

    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:264)

    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448)

    ... 59 more

 

看异常信息大概知道属性wfsj这个字段,不能完成java.util.Date 到 java.sql.Timestamp 日期时间戳的转换。后面还有提示, 没有找到匹配的conversion或editor。

conversion 在Spring中转换对象属性会用到,而editor和converter 以及formatter也是在转换对象(String –> Date, String –> Timestamp),从字符串到对象,从对象到字符串的时候会经常用到。

解决方法:

<bean id="customConfigProcessor" class="com.jp.tic.framework.flex.converter.CustomAmfConversionServiceConfigProcessor"/>

 

<flex:message-broker services-config-path="/WEB-INF/flex/services-config.xml">

    <flex:exception-translator ref="flexExceptionTranslator" />

    <flex:config-processor ref="configProcessor"/>

    <flex:config-processor ref="customConfigProcessor"/>

    <!--<flex:message-interceptor ref="flexMessageInterceptor" />

    <flex:message-interceptor ref="loginMessageInterceptor" />-->

</flex:message-broker>

为message-broker对象注入CustomAmfConversionServiceConfigProcessor对象,CustomAmfConversionServiceConfigProcessor是继承AbstractAmfConversionServiceConfigProcessor对象。

AbstractAmfConversionServiceConfigProcessor对象中提供了对各个类型转换serialization/deserialization的方法。

 

package com.jp.tic.framework.flex.converter;

 

import java.util.HashSet;

import java.util.Set;

import org.springframework.flex.core.io.AbstractAmfConversionServiceConfigProcessor;

 

/**

 * <b>function:</b> 自定义AMF转换服务

 * @author hoojo

 * @createDate 2013-7-17 下午01:35:12

 * @file CustomAmfConversionServiceConfigProcessor.java

 * @package com.jp.tic.framework.flex.converter

 * @project JTZHJK-Server

 * @blog http://blog.csdn.net/IBM_hoojo

 * @email hoojo_@126.com

 * @version 1.0

 */

public class CustomAmfConversionServiceConfigProcessor extends AbstractAmfConversionServiceConfigProcessor {

 

    private static Set<Class<?>> classes = new HashSet<Class<?>>();

    

    @Override

    protected Set<Class<?>> findTypesToRegister() {

        return classes;

    }

}

 

如果你还需要添加更多自己的转化服务,那么你需要给CustomAmfConversionServiceConfigProcessor 注入conversionService对象。

<!-- 添加配置类型转换器、转换服务 -->

    <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">

         <property name="converters">

            <list>

                <bean class="com.jp.tic.framework.mvc.convert.StringToTimestampConverter"/>

                <bean class="com.jp.tic.framework.mvc.convert.DateToTimestampConverter"/>

            </list>

        </property>

        

        <property name="formatters">

            <list>

                <bean class="com.jp.tic.framework.mvc.formatter.SimpleDateTimeFormatAnnotationFormatterFactory"/>

                <bean class="com.jp.tic.framework.mvc.formatter.TimestampFormatterFactory"/>

            </list>

        </property>

    </bean>

 

 

<bean id="customConfigProcessor" class="com.jp.tic.framework.flex.converter.CustomAmfConversionServiceConfigProcessor">

    <property name="conversionService" ref="conversionService"/>

</bean>

Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill的更多相关文章

  1. org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'null' to required type 'double' for property 'band'; nested exception is org.springframework.core.convert.Con

    本文为博主原创,未经允许不得转载: 先将异常粘贴出来: 20:37:26,909 ERROR [com.suning.fucdn.controller.ProductDataStaticsContro ...

  2. Spring系列: 使用aop报错:nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$Refle

    写了个最简单的aop例子 配置文件如下 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns ...

  3. Java AOP nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice || Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0' 两个异常解决办法

    贴出applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans ...

  4. spring和mybatis整合报错:org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError

    Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyExceptio ...

  5. nested exception is java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 14 to TIMESTAMP.

    无法将"0000-00-00 00:00:00"转换为TIMESTAMP 2017-05-08 00:56:59 [ERROR] - cn.kee.core.dao.impl.Ge ...

  6. MyBatis与Spring MVC结合时,使用DAO注入出现:Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    错误源自使用了这个例子:http://www.yihaomen.com/article/java/336.htm,如果运行时会出现如下错误: Invocation of init method fai ...

  7. org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.

    今天报了这个异常,这是页面报的 org.springframework.dao.DataIntegrityViolationException: could not execute statement ...

  8. ?--Porg.springframework.beans.MethodInvocationException: Property 'username' threw exception; nested exception is java.lang.NullPointerException

    使用BoneCP作为连接池,在启动Tomcat报出以下异常: 一月 02, 2016 2:12:17 下午 org.apache.tomcat.util.digester.SetPropertiesR ...

  9. spring整合flex

    在常规的开发中只是用flex二不和后台交互是不可能的,为此flex也提供了和后台交互的2种解决方案一种是Data Services另一种是BlazeDs,本篇博客是用的是后一种,我的开发步骤如下: 1 ...

随机推荐

  1. XE3随笔8:关于乱码

    以下例子都会出现乱码, 虽然都可以有变通的方案, 但如果不乱码就太好了! unit Unit1; interface uses   Windows, Messages, SysUtils, Varia ...

  2. tar 打包命令

    Usage: tar -[cxtzjhmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]... Create, extract, or list ...

  3. ICE系列之3对象接口定义语言——slice

         Slice 定义由编译器编译到特定的实现语言 .编译器把与语言无关的定 义翻译成针对特定语言的类型定义和 API.开发者使用这些类型和 API 来 提供应用功能,并与 Ice 交互.用于各种 ...

  4. redhat 5 中文乱码及中文输入法解决方法

    安装redhat时中文显示乱码(小方框)解决方法 在安装linux的时候,安装完了中文出现乱码或者是当时选错了选成了英文的,到时候中文显示乱码,下面说一下问题的解决: 在首次安装RHEL5时,如果选择 ...

  5. JAVA基础之两种核心机制

    突然之间需要学习Java,学校里学的东西早就忘记了,得用最短的时间把Java知识理顺,重点还是J2EE,毕竟所有的ava项目中95%都是J2EE,还是先从基础的J2SE学起吧....... 首先是了解 ...

  6. 初学layer-------web框架

    第一步,文件的下载   http://layer.layui.com/ 第二步,文件的部署即将包放到web端的相关目录下. 第三步,引用layer.js(此框架是基于jquery的)所以要先引用jqu ...

  7. String reorder

    本问题出自:微软2014实习生及秋令营技术类职位在线测试 (Microsoft Online Test for Core Technical Positions) Description For th ...

  8. submit(提交)按钮

    为form添加一个submit(提交)按钮,点击这个按钮,表单中的数据将会被发送到通过action属性指定的地址上. 下面是submit按钮的例子: <button type="sub ...

  9. 取td里面的内容

    var rowLength = document.getElementById("table名字").rows.length;   for(var i=0;i<rowLeng ...

  10. WPF快速入门系列(1)——WPF布局概览

    一.引言 关于WPF早在一年前就已经看过<深入浅出WPF>这本书,当时看完之后由于没有做笔记,以至于我现在又重新捡起来并记录下学习的过程,本系列将是一个WPF快速入门系列,主要介绍WPF中 ...