Bug in XHTMLManager#isServiceEnabled(...)

I’'m using Smack 1.3.0.

The following call, with xmpp being a valid XMPPConnection and whom being a valid Jabber ID causes the exception below:

XHTMLManager.isServiceEnabled(xmpp, whom);

java.lang.ClassCastException

at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryMa nager.java:263)

at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryMa nager.java:229)

at org.jivesoftware.smackx.XHTMLManager.isServiceEnabled(XHTMLManager.java:165)

at com.buddystream.plugins.jabber.XMPPSession.sendMessage(XMPPSession.java:203)

at com.buddystream.server.ClientConnectionHandler.sendMessage(ClientConnectionHand ler.java:514)

at com.buddystream.server.ClientConnectionHandler.run(ClientConnectionHandler.java :737)

at java.lang.Thread.run(Thread.java:534)

The result variable, which is attempted to be casted into a DiscoverInfo instance is of type PacketReader$4, but I don’'t know where to find that anonymous class.

I fixed the ServiceDiscoveryManager problem by adding the smack-config.xml file to my path.

Then I added the smack.providers file that comes in the javax.jar file in Smack’'s 1.3.0 distribution to my path. I debugged ProviderManager and saw that the extensions and IQ providers were being parsed and -I assume- loaded, too.

I still get the same error, though. Any idea of what could be wrong?

Javier,

I think that you are still having a configuration problem. You are reaching this inner class because Smack was not able to locate the proper IQProvider for the extension whose elementName=query and namespace=http://jabber.org/protocol/disco#info. You can open a debugger and visually check in the “Smack Info” tab the installed IQ Providers. You should find in the list this entry: org.jivesoftware.smackx.DiscoverInfoProvider.

If you do find that entry, I’‘ll recommend posting the received XML from your GAIM client. OTOH, if you can’'t find that entry you will need to make sure that Smack is finding the smack.providers file.

Regards,

– Gato

Well, as I said the configuration is being read. I just verified with the debugger that the particular provider you mentioned is there.

Here’'s the data being transmited:

out:

in: <iq from=’‘him@jabber.org’’ id=’‘8XVOk-5’’ to=’‘me@jabber.org/SomeResource’’ type=’‘result’’/>

Here comes the exception that’'s causing my program to fail.

out: </stream:stream>

in: stream:errorConnection is closing</stream:error></stream:stream>

I’‘m not quite familiar with the protocol, but could be the problem that GAIM’‘s response doesn’'t include the xmlns attribute?

Well, as I said the configuration is being read. I

just verified with the debugger that the particular

provider you mentioned is there.

Ok.

Here’'s the data being transmited:

out: <iq id=“8XVOk-5” to="him@jabber.org"

type=“get”><query

xmlns=“http://jabber.org/protocol/disco#info”>

in: <iq from=‘‘him@jabber.org’’ id=‘‘8XVOk-5’’

to=‘‘me@jabber.org/SomeResource’’ type=‘‘result’’/>

What server are you using? An XMPP compliant server won’‘t pass your IQ stanza to the target user instead it’‘ll answer the IQ. You need to specify the user’‘s resource in the TO of an IQ stanza(e.g. “him@jabber.org/Smack”). This is why you aren’'t getting any info from the other client.

Here comes the exception that’'s causing my program to

fail.

out: <presence id=“8XVOk-6”

type=“unavailable”></stream:stream>

in: stream:errorConnection is

closing</stream:error></stream:stream>

It seems that what is causing the error has nothing to do with your disco request. However, I’'m not sure why is it that you are getting a stream error message.

I recommend adding the resource to your disco request and try again. Let me know if you are still having problems so that I can try to reproduce the problem.

Regards,

– Gato

I’‘m using jabber.org, and messaging works perfectly. I haven’‘t seen the XHTMLManager JUnit test cases that come with Smack specifying the resource, but I must admit that I didn’'t get the chance to run the cases and sniff the connection, I only checked the source code.

I workarounded the problem by not issuing the call and always sending the plain text and XHTML bodies.

Javier,

You are not seeing that XHTMLManager test case specifies a resource because you have an old version of it. I found out the problem when I ran the test case against the jabberd server.

I just connected to jabber.org and sent your IQ disco packet and, as expected, it didn’‘t work. It didn’‘t work because jabber.org uses jabberd (AFAIK) and jabberd does not allow you to send an IQ to a client if you don’'t specify a resource. The server will answer instead of the client. Please, try again adding the resource to your message.

Regards,

– Gato