我有這樣的情況例外:如何捕捉由於外部的JAR
我試圖執行一個命令(DF -h即命令來查找磁盤的可用空間)的數據庫服務器上。我試圖通過使用兩個JAR文件來實現,即jsch-0.1.51.jar和ganymed-ssh2-build210.jar。
現在,當有任何撥錯credentails進入,它會導致以下異常
com.jcraft.jsch.JSchException
但是當我試圖捕獲了異常,它說:
Unreachable catch block for JSchException. This exception is never thrown from the try statement body
和程序失敗我該怎麼趕上這個「com.jcraft.jsch.JSchException」異常。
歡迎任何建議。提前致謝。下面
完整的堆棧跟蹤給定:
Connect fails with the following exception: com.jcraft.jsch.JSchException: java.net.UnknownHostException: Select Option
會話斷開 com.jcraft.jsch.JSchException:會話處於down
在com.jcraft.jsch.Session.openChannel(會話。 java:752) at net.neoremind.sshxcute.core.SSHExec.exec(SSHExec.java:164) at org.nrift.SchMaint.controller.CheckSpaceServlet.doPost(CheckSpaceServlet.java:63) at javax.servlet。 http.HttpServlet.service(HttpServlet.java:647) at javax.serv let.tttt.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain。 java:210)
你能提供完整的堆棧跟蹤嗎? – CodeChimp
儘量只捕捉一般「異常」。 – Xdg
您是否閱讀過這篇文章? [這裏](http://stackoverflow.com/questions/2003419/com-jcraft-jsch-jschexception-unknownhostkey)你的問題是這樣嗎? – TeachMeJava