2014-10-29 3 views
1

Grails 버전 : 2.3.8 에 BootMaster를 등록했습니다. 그러나 BootStrap.groovy을 사용할 때 JSON으로 작성 날짜가 개체, 그것은 예외가 발생합니다 :Grails는 BootStrap에 DateMarshaller를 등록하고, rails.converters.JSON을 grails.converters.XML로 캐스팅 할 수 없다는 예외를 throw합니다.

def customDateMarshaller = new DateMarshaller(FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss'Z'",TimeZone.getDefault(), Locale.getDefault())) 
def init = { servletContext -> 
    JSON.registerObjectMarshaller(customDateMarshaller)` 
} 
+1

Grails의 버전은 무엇입니까? –

+0

Grails 버전 : 2.3.8 –

답변

1

그것은 내 문제입니다 : 예외 메시지는 BootStrap.goovy

ClassCastException: grails.converters.JSON cannot be cast to grails.converters.XML. 

입니다. 동일한 간단한 클래스 이름 인 DateMarshaller를 갖는 두 개의 클래스가 있습니다. 하나는 'org.codehaus.groovy.grails.web.converters.marshaller.xml.DateMarshaller', 다른 하나는 'org.codehaus.groovy.grails.web.converters.marshaller.json.DateMarshaller'입니다. 첫 번째 대신 두 번째 글자를 사용해야합니다.