ClassCastException?

Sorry, my english is so poor.

in PacketReader (line 519 – 524)

// If an IQ packet wasn’'t created above, create an empty IQ packet.

iqPacket = new IQ/u {

public String getChildElementXML() {

return null;

}

};[/i]

when i login google talk, throw the following exception.

and

// If an IQ packet wasn’'t created above, create an empty IQ packet.

iqPacket = new Bind/u {

public String getChildElementXML() {

return null;

}

};[/i]

no exception;

why?


java.lang.ClassCastException: org.jivesoftware.smack.PacketReader$4

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 175)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:352)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:318)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:299)

at com.yoinn.ggrobot.GGRobot.run(GGRobot.java:49)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at com.yoinn.ggrobot.Start.main(Start.java:36)

(405)

at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication .java:62)

at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 216)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:352)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:318)

at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:299)

at com.yoinn.ggrobot.GGRobot.run(GGRobot.java:49)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at com.yoinn.ggrobot.Start.main(Start.java:36)

Hey Linac,

Are you using the “out of the box” smack.jar file? The ClassCastException usually occurs when the file META-INF\smack.providers was not found. If you are building your own deployment then make sure to include the META-INF folder located in build\resources.

Regards,

– Gato

Thanks,

I used Smack source, but when i used Smack.jar and Smackx.jar, the same Exception occurs.

However, when i modify Smack source,

in PacketReader (line 519 – 524)

// If an IQ packet wasn’'t created above, create an empty IQ packet.

iqPacket = new IQ/u {

public String getChildElementXML() {

return null;

}

};

to

iqPacket = new Bind/u {

public String getChildElementXML() {

return null;

}

};

the exception not throw.

Regards,

– Linac

What do you have for imports? Any reference to org.xmpp.*?

org.xmpp.*??

what’'s this?

I have imports org.jivesoftware.smack.* /b .