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.run(Boot.java:247)

at com.simontuffs.onejar.Boot.main(Boot.java:105)

Caused by: java.lang.NullPointerException

at org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.setServiceEnabled(F ileTransferNegotiator.java:119)

at org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.getInstanceFor(File TransferNegotiator.java:100)

at org.jivesoftware.smackx.filetransfer.FileTransferManager.(Client.java:92)

at client.control.Client.main(Client.java:399)

… 6 more

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

Largo,

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?

Thanks,

Alex

Largo,

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.

Thanks,

Alex