locked
try-catch block not catching exception RRS feed

  • Question

  • Hi,

    How to catch exception throws by "ComputeManagementService.create(config)" method? My try-catch block is not catching it.
    Getting "java.io.IOException: Keystore was tampered with, or password was incorrect"  because I am deliberately passing wrong config parameters(incorrect password of keystore file) but not able to catch it. 

    I tried to catch with " throwable" class also but that too is not helping. Thank you.

    SAMPLE CODE 1:

    try {
    SUBSCRIPTION_ID = subId;
    KEYSTORE_PATH = keyPath;
            KEYSTORE_PASSWORD = keyPswd; // wrong password
            uri = new URI("https://management.core.windows.net/");
            config = ManagementConfiguration.configure(uri, SUBSCRIPTION_ID, KEYSTORE_PATH, KEYSTORE_PASSWORD, KEYSTORE_TYPE);
            computeManagementClient = ComputeManagementService.create(config);
    } catch(Exception e) {
    e.printStackTrace();
    }

    SAMPLE CODE 2:

    try {
    SUBSCRIPTION_ID = subId;
    KEYSTORE_PATH = keyPath;
            KEYSTORE_PASSWORD = keyPswd; // wrong password
            uri = new URI("https://management.core.windows.net/");
            config = ManagementConfiguration.configure(uri, SUBSCRIPTION_ID, KEYSTORE_PATH, KEYSTORE_PASSWORD, KEYSTORE_TYPE);
            computeManagementClient = ComputeManagementService.create(config);
    } catch(IOException ioe) {
    ioe.printStackTrace();
    } catch(Throwable te) {
    te.printStackTrace();
    }


    • Edited by Xsur Wednesday, September 16, 2015 5:36 AM
    Tuesday, September 15, 2015 1:11 PM

All replies

  • hi Xsur,

    I am not sure how are you deploying your code, I tend to assume its a worker role.

    in that case printStackTrace wont help because their is no console to print to.. but you can log your exceptions and see if this still is the case. 

    hope this helps


    Vishal Narayan Saxena http://twitter.com/vishalishere http://www.ogleogle.com/vishal/

    • Proposed as answer by vishalishereMVP Tuesday, September 15, 2015 1:57 PM
    Tuesday, September 15, 2015 1:57 PM
  • Hi vishalishere,

    Thanks for your reply.
    We have developed a web application that  used to create cloud services with our own custom image.
    We have console to see every print statement. 

    I guess its a uncatchable exception but not sure how to deal with this. 

    Tuesday, September 15, 2015 2:06 PM