cancel
Showing results for 
Search instead for 
Did you mean: 

jRuby scripting setting up guidelines wanted

zloy
Champ in-the-making
Champ in-the-making
Hi,
I'm new to developing for Activiti bpm. These days I mainly used its REST API, and now I need to make some scripts in jRuby. I looked through Activiti user guide and didn't find any directions how to make avitiviti server to execute scripts in ruby, except that  I should put jruby.jar to CLASSPATH. And I'm feeling kinda learning curve is pretty high.

Can you direct me to certain document, post or howto which might help me with it?

Thank you in advance.
3 REPLIES 3

trademak
Star Contributor
Star Contributor
We have seen a lot of Javascript and Groovy scripts, but jRuby I've not used that much. What kind of direction are you looking for? You should be able to write a jRuby script like you are used to. Process variables will be available as jRuby variables and there's an execution variable that's a DelegateExecution instance which you can use for more complex logic.

Best regards,

zloy
Champ in-the-making
Champ in-the-making
I mainly write in ruby, while java and jruby fields are new to me. This time I need to write a scripting task which propagates process variables to remote REST service. Basically I need to write a script which reads configuration yaml file to instantiate a connection to remote REST service using Faraday gem, and make a POST request.

Yesterday I spent all day to make my hello world script run in script task in test process. It took so long cause I couldn't find any directions how to make activiti run jruby script. Seems it's obvious to java guys, but to me as rubyist it was very unclear. I managed it, picking bits of relevant info over the Internet. Today I spent to figure out how to install and make Faraday gem available to my test script, where to place gems, shall I set special permissions to gem files, etc, and finally I could `require 'faraday'`. And I'm not sure I did it right way. I still can not use bundler, despite it's installed just like faraday:

export GEM_HOME=/var/lib/tomcat6/shared/gems
export GEM_PATH=/var/lib/tomcat6/shared/gems
java -jar jruby-complete-1.7.21.jar -S gem install bundler

My task fails when I put `require 'rubygems'; require 'bundler/setup' in it. But I think I can get along without it.

I found no tutorial how to make activiti use jruby, how to install gems, how to use Gemfile, nor how to write simple scripts which access process variables. Sad, but true, I stuck in every trivial bit of work.

That is why I'd appreciate for any jruby scripting examples.

jbarrez
Star Contributor
Star Contributor
There are some other people trying out JRuby scripting, but it's not very successful: http://forums.activiti.org/content/scripttask-jruby-cannot-access-execution-variable

I'm also not sure if the 'traditional' way of using gems will work. JRuby as a scripting engine is limited and does not read gems like the regular ruby does.

Like Tijs said, we don't see many rubyist passing here, so I can't really help you out with examplex I'm afraid.

Doing a post request with Java is another option of course, which many people here could help you with, but then you'd need to get some Java knowledge of course :s