Code that does not fail in a standalone application behaves differently when embedded in a JSP page. In particular, the server does not respond. The XML stream from the client looks like:
org.jivesoftware.smack.XMPPException: Connection failed. No response from server.
I am interested in using the library from with J2SE J2EE servlets and/or beans. If anyone has a working example in that context, please post it along with changes required to make it so. Thanks…
So, the major problem with this approach is that you’‘re creating a new connection on every single page view. You won’‘t have any way of seeing new messages this way, because the messages will likely arrive between page views. What you really need to do is create a seperate class that keeps a connection object in memory. You could use the user’'s session as a key in the map to lookup the connection for each page view. Does this make sense?
I’'ve been working my app some more, and have found that the .join() method physically joins me to the room but throws the no responce error. I have implemented a Try Catch scenario to keep the error from coming up, but have found because .join() fails I can not use .leave()
I’'d recommend doing all of your Smack testing in a standalone application, as that will be much easier for testing. You can also turn on the Smack debugging mode, which will let you see the XML going back and forth. If you find an error in that case, let me know.