powered by Jive Software

Simple File Transfer Error using Smack

Hello,

I am getting a simple file transfer error when transferring file from a Java client (written using smack) to a spark client.

Has anyone seen this before, any pointers would be very helpful…

Thanks

Drag

The exception that I am getting is:

Exception in thread “AWT-EventQueue-0”

at org.jivesoftware.smackx.packet.StreamInitiation.getChildElementXML(

java.lang.IllegalArgumentException: IQ Type not understood

at org.jivesoftware.smack.packet.IQ.toXML(

StreamInitiation.java:159)

at org.jivesoftware.smackx.debugger.EnhancedDebugger$20.run(

IQ.java:88)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

The Software code is:

public

{

ServiceDiscoveryManager sm=

FileTransferManager m =

new ServiceDiscoveryManager(connection);

FileTransferNegotiator.setServiceEnabled(

new FileTransferManager(connection);

OutgoingFileTransfer t = m.createOutgoingFileTransfer(dest);

connection,true);

File f =

try {

t.sendFile(

new File(“xx.txt”);

}

new File(“xx.txt”), “Here you go”);

catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

The XML Message that I am sending looks good to me from a top level…

Here you go [http://jabber.org/protocol/bytestreams](http://jabber.org/protocol/bytestreams) [http://jabber.org/protocol/ibb](http://jabber.org/protocol/ibb)

EnhancedDebugger.java:774)********** void sendFile(String dest)**

Hi,

this exception can only occur if a StreamInitiation packet of type GET is transformed to XML.

Looking at the source of Smack no Packets like that are created (only type SET and RESULT).

Where does the exception occur? At Spark or at your java client? maybe updating Spark will solve the problem …

BTW: In your code you do some unnecessary stuff. You should alway get an instance of ServiceDiscoveryManager by invoking

ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);

Creating new ServiceDiscoveryManagers confuses Smack because if you do this there are multiple SDMs that may respond to service discovery requests.

Also creating a new FileTransferManager already registers the service at the SDM so you don’t have to do it again.

Best regards,

Henning