Using custom datatype from another module/add-on

Hi,

I have the same problem with the custom datatypes as described by @bank. Here’s the use-case I have:

The entity soft reference addon: GitHub - mariodavid/jmix-entity-soft-reference at cuba-compatability · GitHub (branch cuba-compatability).

There I have two modules:

The CUBA compatibility module jmix-entity-soft-reference-cuba has a dependency on the entity-soft-reference module as you mentioned:

@Configuration
@ComponentScan
@ConfigurationPropertiesScan
@JmixModule(dependsOn = {
        EclipselinkConfiguration.class,
        UiConfiguration.class,
        SoftReferenceConfiguration.class
})
@PropertySource(name = "de.diedavids.jmix.softreference.cuba", value = "classpath:/de/diedavids/jmix/softreference/cuba/module.properties")
public class SoftReferenceCubaConfiguration {

// ....
}

Additionally, I added the JPA entity enhancing information in the cuba module:

    entitiesEnhancing {
        jpaConverters = ['de.diedavids.jmix.softreference.entity.SoftReferenceConverter']
    }

In the jmix-entity-soft-reference module there is a custom datatype SoftReference and the jmix-entity-soft-reference-cuba module has the old CUBA custom datatype: EntitySoftReference.

Now I have set up an integration test in the cuba module, that has a Document entity that contains now references to both datatypes.

The test fails as the application context cannot be started:

ava.lang.IllegalStateException: Failed to load ApplicationContext
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
	at 

// ...

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.jmix.core.impl.MetadataLoader]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Datatype 'SoftReference' is not found
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:311)
	... 157 more
Caused by: java.lang.IllegalArgumentException: Datatype 'SoftReference' is not found
	at io.jmix.core.impl.DatatypeRegistryImpl.get(DatatypeRegistryImpl.java:64)
	at io.jmix.core.impl.MetaModelLoader.getAdaptiveDatatype(MetaModelLoader.java:818)
	at ...

See also CI run.

So for me, the error persists with the configurations you proposed @krivopustov . Can you elaborate on why the problem still exists?

That being said: In a scenario without multi module this problem is not present. If you take a look at the running example: GitHub - mariodavid/jmix-entity-soft-reference-example: Example for using jmix-entity-soft-reference · GitHub - it works without any further customizations other than:

Thanks for the help!
Mario