powered by Jive Software

Programmatically Joining a WorkGroup


I am trying to work out how to programmatically make an agent available in a workgroup to be contacted by a user. I have been looking at the API for the classes in the package org.jivesoftware.smackx.workgroup.agent trying to work out how this is done, or whether this can be done using this library. I have OpenFire installed with the FastPath plugin, and I can get users routed to agents no problem.

Thanks in advance,


I found the call Agent.getWorkgroups() which seems to potentially be on the right path for me, but when I call it I get “feature-not-implemented(501)”, although I had to debug to find this because I was lost in a ClassCastException. I would have thought that given I am running OpenFire with the FastPath plugin I would be able to use this call. Does anyone have any input?



Ok so I am making progress…

By calling: Agent.getWorkgroups(“workgroup.pece”, “test1@pece”, connection)

I get the error:

Exception in thread “main” java.lang.ClassCastException: org.jivesoftware.smack.PacketReader$4 cannot be cast to org.jivesoftware.smackx.workgroup.packet.AgentWorkgroups
at org.jivesoftware.smackx.workgroup.agent.Agent.getWorkgroups(Agent.java:49)
at test.OpenfireTest.main(OpenfireTest.java:76)

I have debuged Openfire and FastPath into WorkgroupManager which is returning:

This all looks correct, so I cannot explain what I am seeing when the response comes back and causes the ClassCastException.

Could this be a bug, or have I made an error somewhere?



Starting to feel a little schizophrenic in here. I have traced the problem to the ProviderManager, which does not have a provider set for the key:


These are loaded from smack.properties. Do I need to have something else on my classpath, or to provide another configuration or something to get this to work?

Also if there is a more appropriate place for me to ask these kind of questions let me know. I’m coming at this from a developers perspective so there may be a more suitable audience available.

Thanks again,


Hi Stuart,

As you’ve discovered you’ll have to add the appropriate IQ provider before you can work with the workgroups. See the code snippet below on how to do that:

ProviderManager.getInstance().addIQProvider(WorkgroupForm.ELEMENT_NAME, WorkgroupForm.NAMESPACE, new WorkgroupForm.InternalProvider());

Hope that helps,


Simple as that eh . Wish I had thought of that earlier.

Thank you very much for your help.



Hello again, I have a follow on question. I have tried your solution and it works, only not as I was expecting. I got a list of workgroups back, but only their names. I was hoping for workgroup objects or something so that I could programmatically make myself available to pick up incoming chats to the workgroup.

I have searched the documentation, the API and the web trying to figure out how I would go about doing this. Do you have any ideas how I should proceeed?

Thanks again,


hello @Stuart.McGregor:

these days ,i have the same problem with you, i want to getWorkgroups from a agent ,but get a " Exception in thread “main” java.lang.ClassCastException: org.jivesoftware.smack.PacketReader$4 cannot be cast to org.jivesoftware.smackx.workgroup.packet.AgentWorkgroups
at org.jivesoftware.smackx.workgroup.agent.Agent.getWorkgroups(Agent.java:49)" , and in the debug i see the data ,as the reply said need to add the appropriate IQProviderManager, i can’t get want to do,if i want to run it , how can i deal with it ?

hoping for your reply ,thank you for your help!!



maybe i use the lastest version of smack.jar ,just from smack_src_3_1_0 doucument, then i change it to older version ,it works,use the jar in spark lib.

thank you