Results 1 to 10 of 10
- 11-04-2009, 03:59 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 2
- Rep Power
- 0
Accessing the lowest exception message
Hi all,
I'm relatively new to Java (4 hrs in) and I've managed to get an SFTP implementation working. However, in trying to break it, I realised that the component (Zehon) that I'm using, raises exceptions with messages that aren't as descriptive as the library it is calling Jsch.
The message I want to return is actually the line:Java Code:04/11/2009 2:12:51 PM org.apache.commons.vfs.VfsLog info INFO: Using "C:\DOCUME~1\trentm\LOCALS~1\Temp\vfs_cache" as temporary files store. org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://temp:***@sftpserver/". com.zehon.exception.FileTransferException: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://temp:***@sftpserver/". at com.zehon.FileTransferClient.resourceExist(FileTransferClient.java:576) at com.zehon.FileTransferClient.folderExists(FileTransferClient.java:551) at com.zehon.sftp.SFTPClient.folderExists(SFTPClient.java:803) at SFTP.IdfJSFTP.jSFTPPut(IdfJSFTP.java:69) at SFTP.IdfJSFTP.main(IdfJSFTP.java:26) Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://temp:***@sftpserver/". at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:99) at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.getFileSystem(AbstractOriginatingFileProvider.java:103) at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:82) at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:66) at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:692) at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:620) at com.zehon.FileTransferClient.getFileObject(FileTransferClient.java:741) at com.zehon.FileTransferClient.resourceExist(FileTransferClient.java:573) ... 4 more Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftpserver". at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:214) at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:90) ... 11 more Caused by: com.jcraft.jsch.JSchException: Auth fail at com.jcraft.jsch.Session.connect(Session.java:452) Unknown Exception at com.jcraft.jsch.Session.connect(Session.java:150) at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:210) ... 12 more
Caused by: com.jcraft.jsch.JSchException: Auth fail
How do I access that?
Regards,
TM
- 11-04-2009, 10:06 AM #2
just if u want to print only the exact messages.
say
try
{
ur code will be here
}
catch(Exception ex)
{
System.out.println(ex);//it prints the eception caused by in single line
}//try-catchRamya:cool:
- 11-04-2009, 10:32 AM #3
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
getCause recursively until you get the one you want?
- 11-04-2009, 06:00 PM #4
Member
- Join Date
- Nov 2009
- Posts
- 1
- Rep Power
- 0
I am trying to use zehon but get a error
"at org.apache.commons.vfs.impl.DefaultFileSystemManag er.setupComponent(DefaultFileSystemManager.java:42 9)
at org.apache.commons.vfs.impl.DefaultFileSystemManag er.setReplicator(DefaultFileSystemManager.java:388 )
at org.apache.commons.vfs.impl.StandardFileSystemMana ger.init(StandardFileSystemManager.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.vfs.VFS.createManager(VFS.java: 89)
at org.apache.commons.vfs.VFS.getManager(VFS.java:51)
at com.zehon.FileTransferClient.getFileObject(FileTra nsferClient.java:729)
at com.zehon.FileTransferClient.resourceExist(FileTra nsferClient.java:573)"
I am not able to figure out the issue?
Any inputs please?
- 11-04-2009, 06:11 PM #5
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Did you read Masi's response? What code did you write to implement that suggestion?
- 11-05-2009, 11:26 PM #6
Member
- Join Date
- Nov 2009
- Posts
- 2
- Rep Power
- 0
masijade,
Thanks for the tip. Worked the charm.
For anyone looking for the same type of thing. To implement I assigned the getCause() of the exception to a Throwable type variable, then evaluated the results.
Regards,Java Code:Throwable chain = e.getCause(); while (chain != null) { chain = chain.getCause(); if (chain == null) break; lastMessage = chain.getMessage(); }
TM
- 11-06-2009, 06:51 AM #7
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Make it generic and write a method called getCauseOfType that takes two parameters. The one is the Exception and the other is the type of exception one is looking for. Put that in an Exceptions class and file it under your utility functions project.
- 11-06-2009, 09:49 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
This is one of those instances where recursion might be a neater solution, but that's just me being awkward...:)
- 11-06-2009, 10:10 AM #9
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
- 11-06-2009, 10:32 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Similar Threads
-
QuickSort highest lowest Situation
By Tenn in forum New To JavaReplies: 17Last Post: 05-06-2009, 04:37 AM -
find the greatest and lowest number in 2D array
By le_albina@hotmail.com in forum New To JavaReplies: 2Last Post: 03-30-2009, 11:09 PM -
Error Message:Invocation Target Exception
By Deepa in forum New To JavaReplies: 1Last Post: 11-27-2008, 07:43 AM -
Display Message Without Throwing Exception
By kailashchandra in forum JavaServer Faces (JSF)Replies: 0Last Post: 09-27-2008, 09:05 AM -
Getting Exception message into a String
By Java Tip in forum Java TipReplies: 0Last Post: 02-04-2008, 09:31 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks