Hi,
I am hitting issues when trying to download a file and get this casting issues. Anyone who has resolved this before, please advice.
com.sun.xml.ws.encoding.MIMEPartStreamingDataHandler cannot be cast to com.sun.xml.internal.org.jvnet.staxex.StreamingDataHandler
[ downloadStream = (StreamingDataHandler) contentServiceClient.downloadContent(contextID); ]
private void downloadNode(ContentService contentServiceClient, String contextID) {
// Create a StreamingDataHandler to download the file with
StreamingDataHandler downloadStream = null;
// Call the downloadContent() method
try {
System.out.print("Downloading file...");
downloadStream = (StreamingDataHandler) contentServiceClient.downloadContent(contextID);
} catch (SOAPFaultException e) {
System.out.println("FAILED!\n");
System.out.println(e.getFault().getFaultCode() + " : " + e.getMessage());
return;
} catch (ClassCastException c) {
System.out.println("FAILED!\n");
System.out.println(" Error : " + c.getMessage());
return;
}
// Stream the download to the local file path
try {
File file = new File(FILE_PATH);
downloadStream.moveTo(file);
System.out.println("SUCCESS!\n");
System.out.println("Downloaded " + file.length() + " bytes to " + FILE_PATH + ".\n");
} catch (Exception e) {
System.out.println("Failed to download file!\n");
System.out.println(e.getMessage());
} finally {
// Always close the streams
try {
downloadStream.close();
} catch (IOException e) {
System.out.println("Failed to close the download stream!\n");
System.out.println(e.getMessage());
}}}