Portal module: Error using a service bean from an app component

Hi, forum followers.

We’re trying to call a service bean, located in an app component from the Cuba-Studio project, through a Spring controller of the Portal module, but the following error appears when portal web starts:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'solicitudController': Unsatisfied dependency expressed through field 'adrecesService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.company.territori.service.AdrecesService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}

Our Cuba-Studio project uses the app component “com.company.territori” and “AdrecesService” bean belongs to this app component.

dependencies {
    appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")
    appComponent('com.company.territori:terri-global:0.1-SNAPSHOT')
    appComponent('com.company.territori:terri-global:0.1-SNAPSHOT')
    appComponent("com.haulmont.reports:reports-global:$cubaVersion")
    appComponent('com.haulmont.addon.restapi:restapi-global:7.2.4')
}

Is there any possibility to use a service bean from an app component through an Spring controller? Is needed to register this dependency in some configuration file to use it from a Spring controller?

I would appreciate any idea to solve the problem.
Thanks in advance.

To use a service from an app component in the portal module of the application, the app component should provide its own portal module which registers the service.

Or you can register it right in the application’s portal module in its portal-spring.xml as described here: Using a Service - CUBA Platform. Developer’s Manual

1 Like