heather
September 1, 2006, 4:36pm
1
i’‘m having a weird run-time error that I don’'t even know how to approach.
Snippet of my code:
BufferedImage image = ImageIO.read(new ByteArrayInputStream (screens[0]));
File screenshot = new File(“snapshot.png”);
screenshot.createNewFile();
ImageIO.write(image, “png”, screenshot);
FileTransferManager transferManager = new FileTransferManager(jabber);
OutgoingFileTransfer transferFile = transferManager.createOutgoingFileTransfer("hsholter@jabber.cssb.mb.ca/vpn2");
try
{
System.out.println(“attempting to send file”);
transferFile.sendFile(screenshot, “desktop screenshot”);
System.out.println(“File transfer has started”);
/*while(!transferFile.isDone())
{
System.out.println(“not done”);
if (transferFile.getStatus().equals(FileTransfer.Status.REFUSED))
{
System.out.println(“file transfer was refused!”);
break;
}
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}*/
}
Hey Heather,
What behavior are you experiencing that is a runtime error? Also, did you know that you can send the stream direct to the other user without needing to send it by writing a file to the file system?
Thanks,
Alex
heather
September 1, 2006, 5:21pm
3
Yeah, I know I can send it as a stream. I want to create it as a file so i have a copy of the image on our server machine.
When I press reject the file transfer - nothing bad happens.
When I press accept on the file transfer - i get that exception spitting out that I posted above.
Heather,
Could you post the complete exception you are seeing?
Thanks,
Alex
heather
September 1, 2006, 6:23pm
5
oh weird, i thought I had that in my original post, now I see that it isn’'t lol.
attempting to send file
File transfer has started
Exception in thread “File Transfer jsi_1870735163590703614” java.lang.ClassCastException: org.jivesoftware.smack.PacketReader$4
at org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.negotiateOutgoingTr ansfer(FileTransferNegotiator.java:381)
at org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.negotiateStream(Outgo ingFileTransfer.java:289)
at org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.access$200(OutgoingFi leTransfer.java:35)
at org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer$2.run(OutgoingFileTra nsfer.java:207)
at java.lang.Thread.run(Thread.java:595)
nut
September 6, 2006, 11:58pm
6
That error looks vaguely familiar from another issue I was having… Try running with -Dsmack.debugEnabled=true.
When the debugger pops up check the smack info tab, and see what IQ Providers and Extension Providers you have loaded. I found the issue was with my classpath, I think it as a smack-config.xml file that wasn’'t on it, or something like that.