how to catch WsAdmin Exceptions with jython, properly - Websphere

This is a discussion on how to catch WsAdmin Exceptions with jython, properly - Websphere ; Hi, I have a problem with the catch of exceptions wiht Wsadmin/jython. This is a snipet of my code: (I know where the error comes from, the point is I want to catch exceptions properly) ... try : print '[ABD ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: how to catch WsAdmin Exceptions with jython, properly

  1. how to catch WsAdmin Exceptions with jython, properly

    Hi,



    I have a problem with the catch of exceptions wiht Wsadmin/jython.

    This is a snipet of my code: (I know where the error comes from, the point is I want to catch exceptions properly)

    ...
    try :
    print '[ABD INFO] Starting application' , app_name
    app_mgr = AdminControl.queryNames( 'type=ApplicationManager,process=' \
    + server + ',*' )
    AdminControl.invoke(app_mgr, 'startApplication' ,app_name)
    print '[ABD INFO] Application' , app_name, 'started'
    except:
    print "++++++++++++++++++++++++++++++++++++++++++++"

    # error_type, error_value, tb = sys.exc_info()
    # print error_type, type(error_type)
    print "-----------------------------------------"
    # print error_value, type(error_value)
    print "message:"
    # print error_value.message
    print "============================================= ==="
    print "Traceback:"
    print "============================================= ==="
    # traceback.print_exception(error_type, error_value, tb)
    traceback.print_exc()
    print "==========END TRACEBACK========================"
    # print_exception




    With the try/ except bock do i get the following message:



    ABD INFO] Executed command: wsadmin -f C:\IBM\WebSphere\AppServer\optionalLibraries\jytho n\thuld_wasadmin\deal_with_exception.py
    [ABD] WASX7209I: Connected to process "dmgr" on node aib-201684CellManager01 using SOAP connector; The type of process is: DeploymentManager
    [ABD] [ABD INFO] Starting application Trade2
    [ABD] ++++++++++++++++++++++++++++++++++++++++++++
    [ABD] -----------------------------------------
    [ABD] com.ibm.ws.scripting.ScriptingException: javax.management.MBeanException: Exception thrown in RequiredModelMBean while trying to invoke operation startApplication org.python.core.PyJavaInstance
    [ABD] message:
    [ABD] javax.management.MBeanException: Exception thrown in RequiredModelMBean while trying to invoke operation startApplication
    [ABD] ================================================
    [ABD] Traceback:
    [ABD] ================================================
    [ABD] org.python.core.PyTraceback
    [ABD] ==========END TRACEBACK========================




    And this is the error message i get without try /except. You see wiht try/except do i get a differend or not komplet error message. ( the part "com.ibm.ws.webcontainer.exception.WebAppNotLoadedE xception: Failed to load webapp: Failed to load webapp: Context root /cards/* is already bound. Cannot start application Cards" is missing)



    [ABD] WASX7017E: Exception received while running file "C:\IBM\WebSphere\AppServer\optionalLibraries\jyth on\thuld_wasadmin\deal_with_exception.py" ; exception information: javax.management.MBeanException
    [ABD] com.ibm.ws.exception.RuntimeWarning
    [ABD] com.ibm.ws.webcontainer.exception.WebAppNotLoadedE xception: com.ibm.ws.webcontainer.exception.WebAppNotLoadedE xception: Failed to load webapp: Failed to load webapp: Context root /cards /* is already bound. Cannot start application Cards
    [ABD]




    So basicly do i have two questions:



    1. How do i catch the WebAppNotLoadedException serperatly.

    ...

    except WebAppNotLoadedException:

    ...

    Does not work?!?!



    2. How do i get the second part of my errormessage?

    (com.ibm.ws.webcontainer.exception.WebAppNotLoaded Exception: Failed to load ...)

    The trick wiht sys.exc_info() just gives me the first part of the error message, not the last part.


    Thank you very much.

  2. Re: how to catch WsAdmin Exceptions with jython, properly

    Hi, Did you try actually trying to catch that particular exception?



    except com.ibm.ws.webcontainer.exception.WebAppNotLoadedE xception:



    Regards,

    Brian

  3. Re: how to catch WsAdmin Exceptions with jython, properly

    hi,



    yes I tried, but doesn't worked. Even the attemp to catch Exception (except Exception did not worked.

  4. Re: how to catch WsAdmin Exceptions with jython, properly

    Hi.



    Just have similar problem with you. I catch it with just "except:" and it seems to do the trick.



    --Dan

  5. Re: how to catch WsAdmin Exceptions with jython, properly

    Hi,



    jes i tried, but that is the point. with the gernal except do i catch every Exception but I want to catch certain Exceptions and deal with this exceptions seperatly.

    And still the other problem is that i do not get the second part of the errror message with the sys.exe_info()

  6. Re: how to catch WsAdmin Exceptions with jython, properly

    Hi,



    I too had faced similar kind of problem. I had tried the following sequence of steps and it seemed to handle WAS exceptions



    1. In the jython script, import the WAS exception that you wish to handle



    from com.ibm.websphere.management.exception import AdminException




    2. Altering the try-except block to catch the exception



    try :
    AdminControl.someFunc()
    except *AdminException*, msg:
    print "caught the exception:" , msg




    3. In the wsadmin script execution statement add option -wsadmin_classpath " \deploytool\itp\plugins\com.ibm.websphere.v61_6.1. 0\ws_runtime.jar" as in the example below...

    Note: The directory "com.ibm.websphere.v61_6.1.0" is specific to the version that is installed, hence substitute accordingly



    wsadmin -lang jython -wsadmin_classpath "C:\Program Files\IBM\WebSphere\AppServer1\deploytool\itp\plug ins\com.ibm.websphere.v61_6.1.0\ws_runtime.jar" -f C:\SampScript.py



    If you had any other means of resolving this issue, pls post them too



    Cheers,

    Krish



    Ref: http://webspherehacks.com/blog/?p=8

  7. Re: how to catch WsAdmin Exceptions with jython, properly

    Hi, i have a similar case and i tried your solution.. it works fine except i don't get the whole exception message

    here is the case

    when i do a testconnection without try/except

    testcon = AdminControl.testConnection(ds)

    i get this:

    WASX7017E: Exception received while running file "/root/bin/pilotage.py"; exception information: com.ibm.websphere.management.exception.AdminExcept ion
    javax.management.MBeanException
    java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: undefined variable: ORACLE_JDBC_DRIVER_PATH

    when i try by applying your example:

    try:
    testcon = AdminControl.testConnection(ds)
    except AdminException, msg:
    print "caught the exception:" , msg

    i get this:
    caught the exception: com.ibm.ws.scripting.ScriptingException: com.ibm.websphere.management.exception.AdminExcept ion: javax.management.MBeanException: RuntimeException thrown in RequiredModelMBean while trying to invoke operation testConnection



    How do I do to get the end of the message that interest me : java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: undefined variable: ORACLE_JDBC_DRIVER_PATH ?

+ Reply to Thread