I have a scenario like this:
I am trying to execute a command (df -h i.e command to find disk free space ) on a database server. I am trying to do so by using two JAR files i.e. jsch-0.1.51.jar and ganymed-ssh2-build210.jar .
Now when there is any worng credentails entered , It causes the below exception
com.jcraft.jsch.JSchException
But when i try to catch that exception it says:
Unreachable catch block for JSchException. This exception is never thrown from the try statement body
and the program fails how can i catch this "com.jcraft.jsch.JSchException" exception.???
Any suggestion is welcomed. Thanks in advance.
The full stacktrace is given below:
Connect fails with the following exception: com.jcraft.jsch.JSchException: java.net.UnknownHostException: Select Option
session is down
com.jcraft.jsch.JSchException: session is down
at com.jcraft.jsch.Session.openChannel(Session.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.servlet.http.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)