Hi All
I developed a spring application and it had some rest controllers in package com.activiti.extension.api and some repositories in package com.activiti.extension.beans. I deployed it in alfresco process services 1.9.0/tomcat/webapps/activiti-app/WEB-INF/lib/ as extension jar then i got problem with beans. The repository beans are not scanned by alfresco process services. My question is
Does alfresco scans custom repositories? If Yes, then please explain me how can i implement it.
Thanks & Regards
Ajay
Solved! Go to Solution.
Hi
Try to use a custom bean annotated as Configuration and ComponentScan with package
com.activiti.extension.conf that would point to your custom package bean. Check here for example: https://dzone.com/articles/spring-component-scan (see Component Scanning Filters).
An example could be the following:
package com.activiti.extension.conf;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
/**
*
* A configuration class which will help get the custom packages scanned
*
* @author Rui Fernandes
*
*/
@Configuration
@ComponentScan(basePackages = {"se.alfresco.activiti.listener"})
@PropertySource(value="classpath:external-script.properties",ignoreResourceNotFound=true)
public class ActivitiExternalScriptExtensionConfiguration
{
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
Hi
Try to use a custom bean annotated as Configuration and ComponentScan with package
com.activiti.extension.conf that would point to your custom package bean. Check here for example: https://dzone.com/articles/spring-component-scan (see Component Scanning Filters).
An example could be the following:
package com.activiti.extension.conf;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
/**
*
* A configuration class which will help get the custom packages scanned
*
* @author Rui Fernandes
*
*/
@Configuration
@ComponentScan(basePackages = {"se.alfresco.activiti.listener"})
@PropertySource(value="classpath:external-script.properties",ignoreResourceNotFound=true)
public class ActivitiExternalScriptExtensionConfiguration
{
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
Hi Rui Fernandes
I implemented the same but I'm still facing the issue. Please look into below details
Stack trace:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.activiti.extension.bean.AssetsAvailabilityRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
Error:
ERROR com.activiti.service.ActivitiEndpointLicenseService - Non-enterprise Activiti endpoint: Activiti app
Here i gives my code sample.
Configuration:
package com.activiti.extension.conf;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
@ComponentScan(basePackages = {"com.mypackage"})
@PropertySource(value="classpath:application.properties",ignoreResourceNotFound=true)
public class MyConfiguration {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
Repository:
package com.activiti.extension.bean;
import java.sql.Date;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.mypackage.entity.AssetsAvailability;
@Repository
public interface AssetsAvailabilityRepository extends PagingAndSortingRepository<AssetsAvailability, Long> {
@Query(value="select * from assets_availability aa inner join assets a on aa.aid = a.aid and a.asset_type=:type and date between :fromDate and :toDate", nativeQuery = true)
public List<AssetsAvailability> findByAssetTypeAndDateBetween(@Param("type") String type, @Param("fromDate")Date fromDate, @Param("toDate")Date toDate);
public AssetsAvailability findByDateAndAid(Date date,long aid);
public AssetsAvailability findByDateAndApsUserId(Date date,long apsUserId);
public List<AssetsAvailability> findByApsUserIdInAndDateBetween(List<Long> apsUserIds, Date fromDate, Date toDate);
}
Spring Dependency:
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
There are other repositories also and all are interfaces. And my entities are in package com.mypackage.entity.
I'm using Repository annotation in package com.activiti.extension.bean. Is it Correct? Please give me the solution.
Thanks & Regards
Ajay
Hi Ajay
Your errors are related with the Spring JPA not with Alfresco Process Services. Maybe you would like to make sure you have your code running first as an independent Spring JPA application and then adapt it as an extension of APS. Anyway my guess is that you may be missing the annotation for @EnableJpaRepositories("com.activiti.extension.bean") on the configuration class.
But as said I would first suggest to get everything working first as an independent JPA application and then merge as an extension of APS. My second suggestion would be to rethink how much you want to include as extension to APS and how much makes more sense to live as a separate app (that can be accessed from APS by REST API for example in a more service oriented way. In general doesnt make sense to implement a subsystem as an APS extension to handle as embedded code other entities as you seem to want to do. Typically you want your bpm (APS or any other one) to call your different services and not running them all internally as embedded code.
Hope it helps.
Rui
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.