I have seen people mention having problems with Smack making connections to chat servers when used in an applet, just want to post a few things I have figured out over the last few days. (as a I side note I think Java Applets should die a slow and horrible death and people should just write normal apps and deploy via Java Web Start…although sometimes, as in my case, we are maintaining existing code so it is a necessary evil for now).
My situation called for connecting to a chat server from an applet and the chat server was not running on the web server the applet came from.
What I found was that since the Smack libraries are a 3rd party jar file they didn’‘t get to play outside the security sandbox just because my applet was signed. I also tried signing the smack libraries with my key and it didn’‘t work. I then tried unjarring the smack libraries, jarring them back up and then signing them. Still wouldn’'t connect because of security exceptions.
My final solution was to package up the smack classes in the same jar file containing my applet and then signing the entire thing. This worked!
So unjar your applet classes in a temp directory of some sort and in the same directory unjar smack.jar and delete META-INF/MANIFEST.MF then repeat for smackx.jar. Do not delete the META-INF directory as it contains some other files that smack needs. Simply delete the MANIFEST.MF file.
Delete the original jar files from the temp directory then jar everything back up and then sign the resulting jar file (I did this step with ANT but do it however you want).
This results in an applet that can connect to a chat server that is not running on the same machine the applet came from i.e. the web server. (Assuming the user accepts your signature).
Hope this info can save someone else from a couple of days of trial and error and frustration.