Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error messages show up differently on Window XP environemnt and Linux

Status
Not open for further replies.

Ngai88

Programmer
Sep 8, 2004
56
US
Hello,
Error messages show up differently on Window XP environemnt and Linux environment.

On the Linux, the error said 'cannot find the page', but when the same code ran on Windows, it shows an error,

com.PTSB.cms.controller.PTSBControllerException: Exception: Error writing file[AccountStats.doc] to proper location [ C:\ftp\pub\I00121\attachments\F003\1095204477140_C:\AccountStats.doc].
java.lang.NullPointerException

I am beginning to wonder if there is a different way to deal with FILENAME in the Window environemnt. One thing I do notice that, in the Linux., the ftp path is /var/ftp/pub/
but on Windows, it is C:\\ftp\\pub\\.....,
Can anyone tell me why this happens and what do I do to resolve this?

Thanks,
Ngai
 
I made the experience, that a file
"\\var\\ftp\\pub\\foo.bar" is found on linux, as well as a file "/var/ftp/pub/foo.bar" on windows.

(if there is one - of course).
"C:\\somthing" will of course not work on linux.

seeking a job as java-programmer in Berlin:
 
Filesystem naming is platform dependent -- *nix uses forward slashes, with the the root being an empty slash. On DOS/Windows-based systems, it's a backslash with a drive letter at the root.

I don't know if anyone has ever done this (surely someone has), but there needs to be an Interface or abstract class defined to isolate your code from these differences. Right now, everyone has to just deal with it, and it's a pain.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Having a second look at the error, I see a second "C:" in the windos-filename:
...95204477140_C:\AccountStats.doc
That's illegal.
But how do you create it?
Some code?

chiph: Since I avoid absolute filenames, I had - to my surprise - no pain at all, as mentioned above.

For user-invokations in a GUI you may use FileChooser to get a valid path, and for configuration-issues you can get the configfile from the user-home, and in this file you may specify different additional paths, which might be modified easily very independently from system to system.

seeking a job as java-programmer in Berlin:
 
I've spent quite some time debugging the error message and try to track down the problem. The debug log messages show the ERROR ,
....

com.PTBS.cms.controller.PTBSControllerException: Exception: Error writing file[AccountStats.doc] to proper location [ C:\ftp\pub\I00101\attachments\F002\1095788545453_C:\Documents and Settings\Administrator\Desktop\AccountStats.doc].
java.lang.NullPointerException

at com.PTBS.cms.controller.MessageComposeController.saveUploadedFile(MessageComposeController.java:1286)
at com.PTBS.cms.controller.MessageComposeController.getMessageDataFromForm(MessageComposeController.java:1086)
at com.PTBS.cms.controller.MessageComposeController.runConfirmUpdateState(MessageComposeController.java:481)

.....and it goes on ......................................

so I investigated the MessageComposeController.java, looked at the saveUploadedFile, the uploadFile is not working. It stopped at bean.setFileName(saveUploadedFile(uploadedFile,request)); See below.

What did I do wrong or didn't do here?

Thanks,
Ngai
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private MsgComposeBean getMessageDataFromForm(ControllerRequest request) throws CrisisControllerException {
try {
final FormData formData = processUpload(request);
MsgComposeBean bean = new MsgComposeBean();
bean.setIncidentId(SessionUtil.getIncidentIdFromUserBean(request));
bean.setSenderId(SessionUtil.getFunctionNameFromUserBean(request));
bean.setSenderName(SessionUtil.getUserNameFromUserBean(request));

//bean.setIpAddress(SessionUtil.getHostUrlIp());
//get server ip address to store in db.
bean.setIpAddress(InetAddress.getLocalHost().getHostAddress());

log.debug("calling getMessageFieldData");
getMessageFieldsData(formData,bean);
log.debug("calling getFileFromForm");

final FileItem uploadedFile = getFileFromForm(formData);
log.debug("....FileItem uploadedFile :" + uploadedFile );
log.debug("checking uploaded file for null and blank filename");
if(uploadedFile != null && !"".equals(uploadedFile.getName()) ) {
if(checkSaveDirectory(request)) {
//save uploaded file to correct incident board directory
//then save name of file into bean
log.debug(".....inside getMessageDataFromForm -- saveUploadedFile:" + (uploadedFile));

bean.setFileName(saveUploadedFile(uploadedFile,request));

log.debug("NOTHING GOT PASS THROUGH AFTER bean.setFileName !!!!");

log.debug(".....setFileName: " + uploadedFile );

if (log.isDebugEnabled()) {
}
}
}
return bean;
} catch (ServletException e) {
throw new CrisisControllerException("Exception: error accessing user's session information.\n " + e, e);
} catch (UnknownHostException e) {
throw new CrisisControllerException("Exception: error retrieving ip address of the server.\n " + e, e);
}
}
 
One more thing, the log message...

log.debug(".....inside getMessageDataFromForm -- saveUploadedFile:" + (uploadedFile));

shows this ...

2004-09-21 10:42:25,484 DEBUG [HttpProcessor[8080][0]] controller.MessageComposeController (com.PTBS.cms.controller.MessageComposeController.saveUploadedFile(MessageComposeController.java:1285)) - ...inside saveUploadedFile...:AccountStats.doc Error to proper location : C:\ftp\pub\I00101\attachments\F002\1095788545453_C:\Documents and Settings\Administrator\Desktop\AccountStats.doc

Thanks,
Ngai

 
Well the location "C:\ftp\pub\I00101\attachments\F002\1095788545453_C:\Documents and Settings\Administrator\Desktop\AccountStats.doc" looks incorrect ... so your method "getFileFromForm(formData);" is not correct.

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top