FileTransferNegotiator null pointe exception in jar

hey there

I’‘m writing an IM client with the smack api. I’'m also using the file transfer function. The app runs well in eclipse, but when I export it as a jar file i get this:

Exception in thread “main” java.lang.reflect.InvocationTargetException

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

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)


at com.simontuffs.onejar.Boot.main(

Caused by: java.lang.NullPointerException

at org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.setServiceEnabled(F

at org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.getInstanceFor(File

at org.jivesoftware.smackx.filetransfer.FileTransferManager.(

at client.control.Client.main(

… 6 more

why does it work in eclipse, but not within the jar file? The smack and smackx.jar are included in the project


Looking at the code there is a possibility that this is a race condition. The only way it appears that a ServiceDiscoveryManager can return null is if the connection isn’'t completly initialized. How quickly are you calling the file transfer getInstanceFor() after you create the connection and log it on?




Looking closer at the code. Is it possible that the XMPPConnection isn’‘t fully initialized before you are establishing file transfer? Do you have more than one thread running, if so you’'ll want to make sure that the XMPPConnection is completly initialized before attempting to use file transfer.