Question

I'm using Spring 3.2 M1 and Hibernate 3.

I was working with formatters to format POJOs (which happen to be Hibernate mapping entities) to their string representation. This was very convenient as it worked the other way around allowing me to bind string values to objects. The config in xml was:

<mvc:annotation-driven conversion-service="conversionService" />

<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
    <property name="formatters">
        <set>
            <bean class="aa.XFormatter" />
            <bean class="aa.YFormatter" />
            <bean class="bb.ZFormatter" />
        </set>
    </property>
    <property name="formatterRegistrars">
        <set>
            <bean class="aa.DateFormatterRegistrar" />
        </set>
    </property>
</bean>

Everything was working fine until I needed to add a custom object mapper (HibernateAwareObjectMapper using jackson-module-hibernate) to get rid of lazy loading issues with hibernate POJOs when jsonifiying responses from the back end. I added this to the above code:

<mvc:annotation-driven conversion-service="conversionService"> 

    <mvc:message-converters>
        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="objectMapper">
                <bean class="cc.HibernateAwareObjectMapper"></bean>
            </property>
        </bean>
    </mvc:message-converters> 

</mvc:annotation-driven>

This had the effect of fixing the lazy loading issue. But a new error surfaced when invoking the formatters (when binding a string to a Date for ex):

org.springframework.context.NoSuchMessageException: No message found under code 'fieldOfX.depended' for locale 'en_US'.
at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:161)...

fieldOfX being a field of type Date that was perfectly formatted from its string representation to its Date/object representation before adding the custom object mapper. And I am curious to know what does depended stand for.

The other weird thing for me is that formatting from object to string seems to work just fine.

To my understanding, formatters are just special converters. And message converters are just another kind of converters. But I'm beginning to sense that I'm wrong on this one.

So what am I doing/understanding wrong? Any help is welcome.

Was it helpful?

Solution

Sorry for wasting everybody's time here but the issue was solved by upgrading to the stable version 3.2.2.RELEASE.

Thank you @Pavel Horal for pointing that out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top