AnsweredAssumed Answered

JRuby, Rails, TorqueBox and Activiti

Question asked by boberetezeke on May 20, 2014
Latest reply on May 30, 2014 by jbarrez
I am starting on a project to use Activiti as a process engine from a rails web application. I am planning to use TorqueBox as my application server. I have successfully created a sample app from the user guide using JRuby. When I try to use that same method start up the Activiti Process Engine inside of a TorqueBox service class, it fails to load the configuration (though it works in the rails console – which is odd). I am not sure how to debug this, also I am not clear on how I should tear down the engine in the stop method.

I searched the forums for jruby and rails and there is not much at all there, so it looks like I am invading virgin territory. I got here after a pure ruby project called 'Ruote' (http://ruote.rubyforge.org) became unmanaged.  I think Activiti looks great, but it may take a little tweaking to run it with JRuby and Rails. I saw a forum post about using JRuby for a scripting task (http://forums.activiti.org/content/jsr223-jruby-still-supported-scripts). Has this been fixed?

Thanks for any help y'all can give.

Below is the service class used to start the process engine:

<ruby>
Bundler.require "activiti-engine"
Bundler.require "h2"

class Activiti
  def initialize(options)
    puts "Activiti#initialize"
  end

  def start
    puts "Activiti#start"
    config_path = "#{Rails.root}/config/activiti.cfg.xml"
    puts "config path = #{config_path}"
    @process_engine_configuration = Java::OrgActivitiEngine::ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(config_path)

    @process_engine = $process_engine_configuration.buildProcessEngine
    puts "process_engine = #{@process_engine}"
  end

  def stop
    puts "Activiti#stop"
  end
end
</ruby>

And here is the error I get:

09:48:10,426 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (pool-1-thread-3) Loading XML bean definitions from class path resource [Users/stevetuckner/Projects/Open-Org/torquebox/torquetest/config/activiti.cfg.xml]
09:48:10,428 ERROR [org.jboss.msc.service.fail] (pool-1-thread-3) MSC00001: Failed to start service jboss.deployment.unit."torquetest-knob.yml".service.activiti: org.jboss.msc.service.StartException in service jboss.deployment.unit."torquetest-knob.yml".service.activiti: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [Users/stevetuckner/Projects/Open-Org/torquebox/torquetest/config/activiti.cfg.xml]; nested exception is java.io.FileNotFoundException: class path resource [Users/stevetuckner/Projects/Open-Org/torquebox/torquetest/config/activiti.cfg.xml] cannot be opened because it does not exist
   at org.projectodd.polyglot.core.AsyncService$1.run(AsyncService.java:52) [polyglot-core.jar:1.18.0]
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) [classes.jar:1.6.0_65]
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [classes.jar:1.6.0_65]
   at java.util.concurrent.FutureTask.run(FutureTask.java:138) [classes.jar:1.6.0_65]
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_65]
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_65]
   at java.lang.Thread.run(Thread.java:695) [classes.jar:1.6.0_65]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [Users/stevetuckner/Projects/Open-Org/torquebox/torquetest/config/activiti.cfg.xml]; nested exception is java.io.FileNotFoundException: class path resource [Users/stevetuckner/Projects/Open-Org/torquebox/torquetest/config/activiti.cfg.xml] cannot be opened because it does not exist

Outcomes