Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-664
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Shay Banon
Reporter: Kenny MacLeod
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

Named converter being ignored

Created: 26/Jun/08 06:54 AM   Updated: 28/Jun/08 08:23 AM
Component/s: Compass::Core
Affects Version/s: 2.0.1
Fix Version/s: None

File Attachments: 1. Zip Archive (2 kB)

 Description  « Hide
I've already posted a forum message about this, but now I've boiled it down to a standalone test case, it seems clear-cut. See attached, which includes a Bean class (which contains a JodaTime DateTime field), a compass Converter for DateTime, a spring context definition, a compass mapping XML file, and a JUnit testcase.

The testcase just tried to load the context, which fails because compass does not locate a converter for DateTime, even though (a) the mapping file specifies which converter to use for that property, and 9b) there's a converter of that name defined in the compass engine config.

Running through the debugger and breakpointing in MappingProcessorUtils line 159 shows that the ClassPropertyMapping knows about the DateTime converter, but MappingProcessorUtils ignores it.

org.compass.core.mapping.MappingException: No converter defined for type [org.joda.time.DateTime]
at org.compass.core.config.process.MappingProcessorUtils.resolveConverterByClass(
at org.compass.core.config.process.MappingProcessorUtils.lookupConverter(
at org.compass.core.config.process.MappingProcessorUtils.process(
at org.compass.core.config.process.MappingProcessorUtils.addInternalId(
at org.compass.core.config.process.InternalIdsMappingProcessor.buildClassMetaDataIds(
at org.compass.core.config.process.InternalIdsMappingProcessor.process(
at org.compass.core.config.CompassMappingProcessor.process(
at org.compass.core.config.CompassConfiguration.buildCompass(
at org.compass.spring.LocalCompassBean.newCompass(
at org.compass.spring.LocalCompassBean.afterPropertiesSet(

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 27/Jun/08 08:20 AM
Looking at your mapping, it seems like you define the converter on the wrong tag. When you define a property mapping, you need to have meta-data mapping within it. The property mapping ability to control a converter is usually not used and by default there is an internal Compass converter that handles property mappings.

The meta-data mapping are the ones that you care about. If you add the meta-data tag, and put the converter on it, then things should work.

Kenny MacLeod added a comment - 27/Jun/08 08:25 AM
OK, I'll give that a try. In principle, however, it doesn't seem right that the use of a converter is dependent on the specification of property meta-data. What if I just want to store that property, not search for it?

The application I'm working on involves storing some fearsomely complex object graphs, but few searchable properties. Having to add a meta-data tag to every property that needs a type converter is going to get mightily tedious.

You said that the converter on the property tag is usually not used... does that mean it can be used, if necessary? If not, why does the schema llow it?

Shay Banon added a comment - 27/Jun/08 09:00 AM
In this case, you should use the managed-id-converter attribute and set that on the property mappings.

By the way, you can also register generic converters that will handle types such as Joda DateTime. In this case you should set the following settings for the converter (this is not exposed in the schema configuration):


This will cause your converter to be the default converter for Joda DataTime class.

Kenny MacLeod added a comment - 27/Jun/08 09:15 AM
Ah, the registered type converter is perfect, thanks. That's what I wanted to begin with, but couldn't find any such thing in the docs - did I miss something?

Intuitively, though, I still think the way I configured things in the original test case should work, but I'll leave that up to you. The global converter mapping does the job for me.

Shay Banon added a comment - 28/Jun/08 08:23 AM
Its basically goes back to the beginning of Compass and its design. The converter applies to the mapping. In Compass, property does not translate to a Resource Property, but the meta-data mapping does.