ClassCastException in Smack Library

Hi all,

I’m currently experimenting with Smack and FastPath and I noticed that with the latest Smack Library (3.0.4) the WorkgroupInvitation event is not fired. After some debugging I discoverd that the following error occurs in the Smack Library:

java.lang.ClassCastException:
org.jivesoftware.smack.packet.DefaultPacketExtension cannot be cast to
org.jivesoftware.smackx.workgroup.packet.SessionID     at thalantyr.smack.workaround.Workgroup.handlePacket(Workgroup.java:591)
    at thalantyr.smack.workaround.Workgroup.access$4(Workgroup.java:551)
    at thalantyr.smack.workaround.Workgroup$3.processPacket(Workgroup.java:144)
    at org.jivesoftware.smack.PacketReader$ListenerWrapper.notifyListener(PacketReader.java:819)
    at org.jivesoftware.smack.PacketReader$ListenerNotification.run(PacketReader.java:799)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)

The “thalantyr.smack.workaround.Workgroup” class is just a copy of the class as it appears in the Smack library with the following added at line 590 for debugging:

try {
     sessionID = ((SessionID)pe).getSessionID();
} catch (Throwable t) {
     t.printStackTrace();
}

According to the API docs (and from what I see in the sourcecode of Smack) the cast shouldn’t be a problem.

I checked my classpath for double libraries etc. but I can’t find anything of the sort.

Edit: I should probably mention that if I use the smack libraries (smack.jar, smackx.ajr and workgroup.jar) which are packaged with webchat.jar I have no problems whatsoever.

I have a concern that the workgroup API as it is in workgroup.jar from fastpath, and the code in Smack, aren’t the same version. That might explain why it’s upset. Of course, I wouldn’t expect the workgroup stuff in smack to be incompatible with smack itself. raise eyebrow I don’t have any ideas at the moment, just brain dumping a couple of thoughts.

> java.lang.ClassCastException:
> org.jivesoftware.smack.packet.DefaultPacketExtension cannot be cast to
> org.jivesoftware.smackx.workgroup.packet.SessionID

That error means that Smack does not know how to parse that extension so it used the default parsing but then something was expecting a SessionID so the casting failed. This problem is solved by registering the packet extension parsers that you use.

Regards,

– Gato

That was it! Thanks!

Stupid question perhaps; but why aren’t all packet extensions which are present in smackx.jar declared in the smack.providers file in smackx.jar ?