Jython Examples

I am looking for some example code for using SMACK to send a message from a Jython script. We have a business integration package that supports Jython scripts as actions, but my primitive Jython skills haven’'t been able to get me far.

I can -

import org.jivesoftware.smack as smack;

  • but when I try to create an object I get -

conn1 = smack.XMPPConnection(“mormail.com”);

Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.ServiceDiscoveryManager

Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.XHTMLManager

Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.muc.MultiUserChat

Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.ServiceDiscoveryManager

Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.XHTMLManager

Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.muc.MultiUserChat

Am I missing some required additional initialization?

I’'ve gotten the following example to work:

#!/usr/bin/jython

import org.jivesoftware.smack as smack;

import org.jivesoftware.smack.packet as packet;

xmppConnection = smack.XMPPConnection(“mormail.com”);

xmppConnection.login(“adam”,"******");

presence = packet.Presence(packet.Presence.Type.AVAILABLE);

presence.setStatus(“I am a program”);

xmppConnection.sendPacket(presence);

xmppChat = xmppConnection.createChat("adam@mormail.com");

xmppChat.sendMessage(“Test from smack!”);

xmppChat.finalize();

xmppChat.leave();

xmppConnection.close();