Hi Guys,
I am using activiti-context.xml in order to initialize Activiti Process Engine. When I invoke ProcessEngines.init() method then internally it loads the activiti-context.xml resource from the class path and invokes following method -
protected static void initProcessEngineFromSpringResource(URL resource)
{
try
{
Class<?> springConfigurationHelperClass = ReflectUtil.loadClass("org.activiti.spring.SpringConfigurationHelper");
Method method = springConfigurationHelperClass.getMethod("buildProcessEngine", new Class[] { URL.class });
ProcessEngine processEngine = (ProcessEngine)method.invoke(null, new Object[] { resource });
String processEngineName = processEngine.getName();
ProcessEngineInfo processEngineInfo = new ProcessEngineInfoImpl(processEngineName, resource.toString(), null);
processEngineInfosByName.put(processEngineName, processEngineInfo);
processEngineInfosByResourceUrl.put(resource.toString(), processEngineInfo);
}
catch (Exception e)
{
throw new ActivitiException("couldn't initialize process engine from spring configuration resource " + resource.toString() + ": " + e.getMessage(), e);
}
}
while calling buildProcessEngine() method of org.activiti.spring.SpringConfigurationHelper , it throws exception - No such method error exception….why because In SpringConfigurationHelper class, buildProcessEngine method defined as Private. May I know the reason why It made it private from version 5.17.0 onwards. It works fine for me If i use Activiti 5.14.0 version Since the same method was defined as public before.
activiti-spring-5.17.0 —–>
class SpringConfigurationHelper
{
private static Logger log = LoggerFactory.getLogger(SpringConfigurationHelper.class);
private static ProcessEngine buildProcessEngine(URL resource)
{
log.debug("==== BUILDING SPRING APPLICATION CONTEXT AND PROCESS ENGINE =========================================");
ApplicationContext applicationContext = new GenericXmlApplicationContext(new Resource[] { new UrlResource(resource) });
Map<String, ProcessEngine> beansOfType = applicationContext.getBeansOfType(ProcessEngine.class);
if ((beansOfType == null) || (beansOfType.isEmpty())) {
throw new ActivitiException("no " + ProcessEngine.class.getName() + " defined in the application context " + resource.toString());
}
ProcessEngine processEngine = (ProcessEngine)beansOfType.values().iterator().next();
log.debug("==== SPRING PROCESS ENGINE CREATED ==================================================================");
return processEngine;
}
}
activiti-spring-5.14.0——>
class SpringConfigurationHelper
{
private static Logger log = LoggerFactory.getLogger(SpringConfigurationHelper.class);
public static ProcessEngine buildProcessEngine(URL resource)
{
log.debug("==== BUILDING SPRING APPLICATION CONTEXT AND PROCESS ENGINE =========================================");
ApplicationContext applicationContext = new GenericXmlApplicationContext(new Resource[] { new UrlResource(resource) });
Map<String, ProcessEngine> beansOfType = applicationContext.getBeansOfType(ProcessEngine.class);
if ((beansOfType == null) || (beansOfType.isEmpty())) {
throw new ActivitiException("no " + ProcessEngine.class.getName() + " defined in the application context " + resource.toString());
}
ProcessEngine processEngine = (ProcessEngine)beansOfType.values().iterator().next();
log.debug("==== SPRING PROCESS ENGINE CREATED ==================================================================");
return processEngine;
}
}
For workaround, I overrides SpringConfigurationHelper class in my source code to make it work on Activiti 5.17.0 version.
I would like hear some alternative suggestion on this topic.
Thanks,
Rajiv Ranjan