Hi,
I’‘m using Smack 1.3.0 and I found out that ServiceDiscoveryManager as well as XHTMLManager (and maybe others) use a static body to add themselves as ConnectionEstablishedListenerS. The problem is that -at least with Sun’'s client VM 1.4.2- in order for the static body to be called the class must have been previously referenced.
That is a problem when you reference one of these classes from a ConnectionEstablishedListener handler or even from the same block that calls the XMPPConnection#login method, for instance to set yourself as a not-XHTML-IM-capable client. As it might be the first time that the program accesses those classes, they haven’‘t been yet initialized, that means they didn’‘t have a chance to add themselves to the CEL handlers list, therefore they don’'t get called when the connection is established and you get a NullException.
I workarounded with the following code within the static initializer of my class:
try {
Class.forName(“org.jivesoftware.smackx.ServiceDiscoveryManager”);
} catch (ClassNotFoundException e) {
e.printStackTrace(System.err);
System.exit(1);
}
I suggest fixing this by using lazy creation of the object in the case of ServiceDiscoveryManager.
I also don’‘t think it’‘s a good idea to add a CEL handler automatically to enable the XHTML service, as it might override the application’'s preferences set from that same handler, depending on the order in which the handlers were added to the list.