Intalio|BPP and XMPP

This subject is dear to my heart but frankly low level priority.

I looked at a way for our product, Intalio|BPP, to interact with a XMPP server. Apparently, there are some libraries that deal with this. The XMPP4R library, the XMPP lib that comes with ServiceMix, are two alternatives.

I tried to use XMPP4R with JRuby, but apparently there is a bug in JRuby that makes it hang. I never got the message through anyways.
I don’t feel like playing with ServiceMix.

So, to the heart of the matter: I asked the guys on jabber.org if they have a WSDL to interact with the server.
I understand that the server may have bindings with XMPP, eventually HTTP ?
I have seen reports about Axis2 supporting XMPP as transportation layer, so eventually we could get that.

What do you think ?

Now the folks on jabber.org never came back to me. Am I missing something ? Is there another place where I should be looking ?

Build a REST web service Royal Canin Style

Introduction

As an Intalio employee, I participate to the Intalio Dogfood project. I came too early to the office one morning, had an interesting discussion with the CEO that ended on his team.

The schedule for building our marketing process is aggressive as we want to maximize the ROI. At the same time, it makes use of a lot of technologies that will push our platform in all directions.

Later, on the very same day he had recruited me, he and showed me his first attempt at defining the process we would be working on. And well, instead of a BPMN diagram, he showed me a spreadsheet.

As David French says, that’s really not an “IT developer style of solution”. Yep, it’s business all the way, but my IT skills are there to make it happen. So…

At first, we thought it would be ok to generate a BPMN diagram, and then BPEL, from the spreadsheet, but that was too complex ; that also meant the spreadsheet would contain way more information, in particular the data and the mappings.

Rick Geneva joined our team then and proposed to go for a diagram that would poll the spreadsheet for data, and execute depending on the content of the cells. So it was that simple: I had to design a web service that would take the URL of the published spreadsheet and would turn it into XML data to be fed into the process.

Why REST ?

I have a little knowledge of building web services, I designed one for the Facebook application I had put online in 2007. It was smartly using FCGI and Ruby to produce SOAP messages. I had got the recipe from Pascal who had designed the Time Service in the same way.

However, the Dogfood project required that I integrate the application with our Java server, so I had to try new things.

I didn’t feel like writing the service in Java as I wanted it to be as short as possible. I have a good experience of Ruby now and wanted to see some of it in action.

As a matter of fact, the SOAP libraries in the Ruby world are not doing too well. Some are deprecated, some are still relevant but somehow they don’t inspire much confidence.

So I chose to build a REST service as there is more community around it, at least in the Ruby world.

Micro-frameworks

Assaf pointed me to Rack, a framework to run web applications. I didn’t want to run a full fledged Rails application for a simple web service that had no need for storing data or even html pages.

I first settled for Camping. It was a smart and good looking framework. It was looking enough like Rails, separating the models, the controllers and the views that I thought I would be safe with it. However it wasn’t possible for a controller to render text directly, so the code wasn’t too DRY, and I didn’t find a way to catch the body of the request.

I then approached Sinatra. What a cool framework. Sinatra defines a REST service in three lines:

get "/" do
  return "Hello world!"
end

On top of that, it is possible to gain access to the body of the request: url = @request.body.read

I designed my Sinatra application, then ran it very directly with ruby:

$>ruby lib/csv2xml.rb

To test your application while it is running, you can just send something via wget:

wget http://localhost:4567/ --post-data=your-data --header="Content-Type:text/xml"

Installing and running jruby-rack

The objective is to deploy on a Java web server, remember ? Assaf had pointed me to jruby-rack. The author of the library is Nick Sieger, a member of the JRuby team. The jruby-rack gem installs on top of JRuby and requires to have maven installed. It all went smoothly though.

Once installed, I went looking for examples in the github repository and found some instructions to bundle my Sinatra application:

1. add a config.ru file at the root of your repository. That file should contain the minimum set of instructions to run. See mine for example.
2. Run rackup config.ru to make sure everything works.

So far, so good. The hard part starts now.

Warble me already!

To transform your application into a war, Nick created a gem named warbler.
You run it like this on your application: jruby -S warble war

It’s going to create a .war file. Leave it there and take a little time to review the code dumped into tmp/war/.

  • First, check that web.xml doesn’t contain invalid characters. Your config.ru file was pasted in there, and the XML is escaped. I filed a bug for this, and Nick fixed it promptly, so you shouldn’t have to face it anymore hopefully.
  • Second, check the version of jruby-rack used in the lib folder. It must be at least 0.9.4 for everything to run smoothly. Otherwise, Sinatra will complain of a missing library.

If your need to, make changes and jar again the /tmp/war directory contents with

jar cf csv2xml.war  -C tmp/war .

Deploy to your server. For the Dogfood project, we will be using Tomcat. So I dropped the war in the webapps folder of Tomcat. It was recognized and expanded as a folder.

Then you can try the same operation on your server as the one you were doing when running the application locally:

wget http://localhost:4567/ --post-data=your-data --header="Content-Type:text/xml"

Integrating with Intalio|Designer

REST connector for Intalio|Designer 5.2.1

I discovered while trying to integrate with ODE that it would not be able to send plain-text requests, ie I can’t send “http://www.intalio.com” to a REST service because we have an issue extracting the text node from the element I pass to the service ; I filed a bug about it.

So for this service we will need to use XML all over. For the input, we just want to have an element wrapping a text node ; for the output we need to return a complete tree of the cells of the spreadsheet.

I wrote the xsd by hand in Intalio|Designer. I forgot the maxOccurs attribute :( but it was quickly fixed, thanks to Pascal. I particularly enjoyed writing my XSD directly as I could see the result in the process explorer every time I saved the file.

I used the REST connector that was added to Intalio|Designer as of 5.2.1 to design the WSDL of the service.
I just had to punch in the URL and the parameters I wanted to use.

I used a test diagram to run my service. It queries the service for me and returns its response to my console.

During that phase, I had to do some debugging. In that case, you should open the log4j.properties file of the server and change the org.apache.commons.httpclient category to DEBUG. That way you will see everything that gets in and out of the server.
I also pushed org.apache.ode to DEBUG to get more information on the process state.

My biggest obstacles were to parse the XML sent to get the text without doing any magic…
I settled for using REXML, and using this code does the trick:

url = @request.body.read # Get the request body
  url.gsub!(/\n/, '') #Remove any newline characters as REXML chokes on them.
  doc = REXML::Document.new url // create a new document
  url = REXML::XPath.first( doc, '////text()' ).to_s // look for the most embedded text() node

… and to return XML that was in the schema namespace.

I had to make sure I would use a prefix for each element (”csv2xml”) and that the target namespace and the namespace were both declared.

x.csv2xml :content, {"xmlns:csv2xml" => "http://www.intalio.com/csv2xml",
                       :targetNamespace => "http://www.intalio.com/csv2xml"}

And then it all worked… I got my XML back!

<?xml version="1.0"?>
<csv2xml:content targetNamespace="http://www.intalio.com/csv2xml" xmlns:csv2xml="http://www.intalio.com/csv2xml">
  <csv2xml:row>
    <csv2xml:cell/>
    <csv2xml:cell>B</csv2xml:cell>
    <csv2xml:cell>C</csv2xml:cell>
  </csv2xml:row>
  <csv2xml:row>
    <csv2xml:cell>1</csv2xml:cell>
    <csv2xml:cell>1-B</csv2xml:cell>
    <csv2xml:cell>1-C</csv2xml:cell>
  </csv2xml:row>
  <csv2xml:row>
    <csv2xml:cell>2</csv2xml:cell>
    <csv2xml:cell>2-B</csv2xml:cell>
    <csv2xml:cell>2-C</csv2xml:cell>
  </csv2xml:row>
</csv2xml:content>

All the code used in this blog post is available on Github under the GPL license.

Thanks for the help of nicksieger and rtomayko on #jruby and #sinatra.

Can’t ssh your box ? Stop messing with /etc/shadow!

I had the weirdest error ever. I could connect with a public key to my remote user. The key was showing as accepted. Yet the connection was closed on startup.


debug1: Server accepts key: pkalg ssh-rsa blen 256
debug2: input_userauth_pk_ok: fp ***
debug1: read PEM private key done: type RSA
Connection closed by 128.128.128.128

The solution was to look in /etc/shadow. There was a typo in the file.

Note that I didn’t find a trace of the problem in the syslog, messages, dmesg, etc.

Posted in Notes. No Comments »

Prism and Minefield

I used Minefield for a few months and somehow it managed to keep the RAM busy at all times. I switched to Prism, and things got back into control. Not sure what the difference between the product is, I’m just happy I stopped participating to global warming that much.

Posted in Notes. No Comments »

How to add custom navigation links on the wiki.eclipse.org left bar

This proved to be well hidden ; you can add your own links to the left bar of the wiki.eclipse.org website by adding them individually to the project metadata.

leftnavbar-project-metadata

  1. Log into portal.eclipse.org with your committer credentials
  2. Go to your project, and click on “Maintain project meta-data”
  3. Click to edit the “project left nav” property
  4. Now you can enter your link information:
  5. Just save it, and do it as often as needed.
  6. Go to your wiki page and edit it
  7. Add this to the page: {{#eclipseproject:your.project.id}}
    I prefer using a template for this though.

Eclipse committers, turn your NLS warnings on

I just came to realize that it is possible for the Eclipse compiler to track the missing NON-NLS entries, ie it can detect non-externalized strings.

Please consider opening your Eclipse, go to the preferences, then open Java>Compiler>Error/warnings and look for the option “Non-externalized strings”.

Please push that option so that it issues warnings whenever it finds a non-externalized string.

Otherwise, I’ll keep sending people to the cross-project list, or I’ll ask the AC to consider setting the non-externalized string flag as an error when compiling the Galileo RCs. I hope I won’t have to do that.

EMF::acts_as_ActiveRecords

Not sure you followed the latest news about Intalio, Inc. We just rolled out a new website, and we are introducing a new project named Dogfood.

The Dogfood project is exactly what it looks like: we are going to line up and eat our own software until it makes us sick of it. And then we will have some more.

As part of the project, I am tasked to find a way to transform a spreadsheet with some clear conventions into a fully executable process.
Our BPMN model being EMF-based, I showed it to the team, and we feel it’s simple enough that we can generate the XML from the spreadsheet.

How do you generate a EMF-generated model those days ? You would fire up Eclipse, open the diagram editor and modify what you see on screen. Or you would open the default tree editor and make some changes.

Here, we are looking at a different story. Indeed we want to generate our model without Eclipse. And why not without Java.

My idea is to use the ActiveRecord way to generate a model by reading the ecore file(s). The bright part of the idea is that you can have ActiveRecord read the ecore files and load up the classes in memory. There is no actual generation. You change the ecore file, run again, everything is here.

My hope is to be able to do this:

p = new Pool
activity = new Activity
activity.name = "sample activity"
activity.graph = p
other_activty = new Activity
other_activity.graph = p
s = new SequenceEdge
s.source = activity
s.target = other_activity

Did someone think of doing something like that before ? Is there someone crazy enough to read ecore files and create the metamodel inline around ? Does someone know of a way to use ActiveRecords with something that isn’t a DB table ?

Eclipse and the lone developer

Ketan asked the Architecture Council yesterday what they should be doing for him.

He is working on a pet project, that he brought to maturity on his own. He joined Eclipse to get more support, and hopefully more coverage.

There is a price when you join Eclipse though ; you have to obey to the guidelines, use SVN or CVS, learn how to use Phoenix.

The Eclipse website is actually backed by CVS. My major concern for that practice is that everything that is checked on the website has to have a wipe-cleaned IP, as much as the IP of our code. So, for example, there is no jQuery support on the eclipse.org website. The Eclipse staff waited for six months or so for the IP of YUI to be accepted. That’s really too bad, I only needed jQuery dumb UI functions to make my website look good, I will have to learn YUI instead. Oh well.
The bottom of the issue is that the Eclipse Foundation wants to have a unified UI. I think. Well, Higgins website is quite different from the rest of the website. So I guess you could go ahead, and hack your own thing -in PHP on the Eclipse.org CVS, that is, alas.

To reply to you informally, Ketan, you are not going to get any help from Eclipse on the short term. The organization is a monolith targeted at companies. I feel your pain, and I think you should consider keeping two repositories, one on github, one on Eclipse, and do a synchronization every now and then. As long as you wrote all the code, it’s ok. If someone wants to contribute, he should clone your github repo, make a patch, and attach it to a bug. As long as you can go on like this, it should be ok.

On the long term, the IP policies are important at Eclipse, and I hope that you’ll like using Babel to internationalize your code. I also think that moving to Eclipse is giving way more coverage to your code and your project. Didn’t you have some requests from the platform committers last week on IRC ?

I think you started a nice conversation, and I’m sure the AC and yourself would have some cool ideas for Eclipse to help the lone developer. I just wish it was as easy to open an Eclipse project as it is to open a Rubyforge one.

Eclipse batch compiler: what’s in the jar ?

So I was annoying one person too much with Eclipse and how it rules the universe, and he asked back: what is exactly the Eclipse batch compiler doing ?

So I just went to the Eclipse website, and looked for the Eclipse compiler. I ultimately found out the page where release notes are posted, you need to look at each version to get an idea though.

The Eclipse help system for sure has a nice documentation on how to use the compiler, but it doesn’t explain in too much detail what it does.

This post by Wayne, yet again naked in icy water, was more insightful.

It does wonderful things. My personal favourite thing about the Eclipse Java compiler is the fact that it will compile code that contains errors. That is, when you compile code that has errors in it, the compiler will flag those errors for you and then generate the .class file anyway. You can actually run and debug the code and, should the runtime actually run into your errors, it will then throw an exception.

So now I’m looking if someone compiled a feature list of the compiler somewhere in case I missed something. If you happen to have one hanged to the wall, I’d take it happily.

jBPM integrates the BPMN modeler

I’m not sure if jBPM uses the code from JWT or STP-IM, but it apparently created a powerful transformation wizard to transform BPMN into jPDL.

I’m glad they chose the BPMN modeler as the base for their work.

jBPM folks, would you like to be listed on our integrators page ? If you like your ride with our project, please consider sending a quote!