Can not find the Scheduled Task service class

Hi there,

We are trying to put a service into Scheduled Task that sweep the product table to find if a product inventory fall below a threshold to trigger re-order.

We created two files in core module: The interface is ProductReorderService.java, and the bean is ProductReorderServiceBean.java annotated with @Component. Please find the snapshot of the two files and the build log attached.

What we are missing here? Should the ProductReorderServiceBean also need to be declared in:
modules\core\src\spring.xml or something?

Any help is much appreciated.

-Mike

ProductReorderService

ProductReorderServiceBean

localhost.2016-08-11.log (50.2K)

Update: I found MY problem.

My problem was that while ProductReorderService and ProductReorderServiceBean were correctly in core modules, they somehow mistakenly also exist in file modules\web\src\web-spring.xml:

<bean class="com.haulmont.cuba.web.sys.remoting.WebRemoteProxyBeanCreator">
    <property name="clusterInvocationSupport"
              ref="cuba_clusterInvocationSupport"></property>
    <property name="remoteServices">
        <map>
            <entry key="posportal_ProductReorderService"                                                  <<<<<<<< 
                   value="cloud.pospro.posportal.service.ProductReorderService"></entry>       <<<<<<<< These two lines should not be in web module
        </map>
    </property>
</bean>

Once I removed the two lines marked by <<<<<<<< above, only keep ProductReorderService.java and ProductReorderServiceBean.java files in core module, the scheduled method is being called correctly as expected.

Thanks,
-Mike

Hi Mike,
Perhaps you first created your bean as a service, and services are not supported by scheduled tasks. However, the mechanism of selecting available beans considers @Service annotation and does not pay attention to the registration of the service in the client’s spring.xml (see com.haulmont.cuba.core.app.AbstractBeansMetadata#getAvailableMethods).
So I doubt that the reason was this XML registration, but anyway - good to hear that the issue is over.

Hi Konstantin,

You are right. I DID firstly create the bean as a service from the Studio “SERVICES” menu. Later on when I read the manual and understood that the Scheduled Task beans must be in core module and must be annotated by @Component, I forgot to remove the initially created service.

Regarding removing the registration from modules\web\src\web-spring.xml that “makes” it working, I am NOT sure if those two lines were the reason. I just simply wanted to follow the requirements in the manual and get rid of everything else, and I believe those two lines in web-spring.xml should not be there.

Thanks for the help,
-Mike