Cannot guess id for datatype for a custom datatype on version 6.8.6


I have created a custom datatype (currency) with an entry in metadata.xml:

<datatype id=“currency” class=“com.paslists.prm.entity.CurrencyDatatype”/>

The class itself is defined like this:

public class CurrencyDatatype extends NumberDatatype implements Datatype<BigDecimal> {

My field is declared as:

@MetaProperty(datatype = “currency”)
@Column(name = “AMOUNT”)
protected BigDecimal amount;

The error message I get when Tomcat starts is:

2018-04-18 18:33:26.824 ERROR [localhost-startStop-1] com.haulmont.cuba.core.sys.MetadataLoader - Fail to load datatype 'com.paslists.prm.entity.CurrencyDatatype’
java.lang.IllegalStateException: Cannot guess id for datatype currency

What have I done wrong?


You can get this error if you have an old datatypes.xml file in the classpath root, which also contains the currency datatype but defined by old rules. Please check and remove this file if exists.