cancel
Showing results for 
Search instead for 
Did you mean: 

Error Initializing Activiti Process Engine using version 5.17.0

rajiv_cusat
Champ in-the-making
Champ in-the-making
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
7 REPLIES 7

vasile_dirla
Star Contributor
Star Contributor
Hi,
I'm not aware of a reason for this change, but since it is the only method in this class i don't see any reason to have it "private static".

It seems to be a bug in my opinion. (could you please open an issue?)


please use specific tags when you put code in the message.  Smiley Wink
It's much better to have a clear separation between the message itself and the code sequence.

rajiv_cusat
Champ in-the-making
Champ in-the-making
Hi Vasile,
                 Thank you for the response. Could you please let us know where we should open an issue to fix above bug permanently ?
Thanks,
Rajiv Ranjan.  

jbarrez
Star Contributor
Star Contributor

fconrady
Champ in-the-making
Champ in-the-making
Hi,

I had the same error, but the fix

https://github.com/Activiti/Activiti/commit/87450bc90d4c003e564d3ca1adf89fa409e6b2c6

alone did not resolve it for me. With this I got again the error "cannot access member of class" except that "modifiers private static" was replaced by "modifiers public static". To make it work I had to make the class SpringConfigurationHelper itself public.

Is there a better way?

Thanks
Florian

jiacheo
Champ in-the-making
Champ in-the-making
Hi fconrady, for spring integration, you must config the  org.activiti.spring.SpringProcessEngineConfiguration instead of the org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration .

ykphuah
Champ in-the-making
Champ in-the-making
Just faced this, from the commit it seems that this doesn't go into 6.0.0 BETA1? Which is the (latest) version that I should use that do not have this issue?

vasile_dirla
Star Contributor
Star Contributor
Hi,
you could download the sources (master) and build a new jar for 5.18.
Activiti 6 is still beta and you could use it for playing with it but as you know a beta product is not recommended to be used in production.