Date Created: Sun 09-Nov-2008

Related Document Categories:

Get my WebSphere Application Server course here >>

    How to create a Jython script using the Application Server Toolkit 6.1

    install & Launch the Toolkit

    File >> New >> Other

    Select Jython Project

    We are going to create a project that deals with listing WebSphere Application Servers (WAS) servers

    In the project explorer, right-mouse-click the ListServers project and select New >> Other >> Jython Script File

    Call the file

    Creating a server

    You can create a server to identify the runtime environment that you want to use for testing your project resources.
    To create a server:

    In the menu bar, click File >> New >> Other.

    Expand the Server folder and then select Server.

    Click Next. The New Server wizard opens. This wizard defines a new server, that contains information required to point to a specific runtime environment for local or remote testing, or for publishing to an application server.
    In the Server's host name field, you can provide the fully qualified DNS name or IP address of the host machine that where the server is running. By default, this field is pre-filled with the default address: localhost

    Click Finish. The new server appears in the Servers view under the Server column

    I installed WebSphere 6.1 for Developers, but you could use a WAS 6.1 runtime that comes with RSA 7.x

    So I am going to use this runtime

    Finish as we do not yet have our project completed. You will see a new server profile listed in the server view

    Administrative Console Command Assist - a new feature of the WebSphere administrative console that displays the wsadmin command that is equivalent to the action taken by the end user interacting with the console. The output from the Command Assist feature can be transferred directly to the Jython Editor, making development of Jython scripts based on console actions easy. The Command Assist output can also be saved in a plain text file for later use.

    What I am going to do is now start the server and see if I can get his automatic transfer to a Jython editor.

    If you double click on the tab the panel will go full screen

    If you get the error

    [09/11/08 13:32:22:718 GMT] 00000014 RoleBasedAuth A SECJ0305I: The role-based authorization check failed for admin-authz operation Server:getName. The user UNAUTHENTICATED (unique ID: unauthenticated) was not granted any of the following required roles: adminsecuritymanager, administrator, monitor, configurator, operator, deployer.
    [09/11/08 13:32:27:171 GMT] 00000014 RoleBasedAuth E SECJ0306E: No received or invocation credential exist on the thread. The Role based authorization check will not have an accessId of the caller to check. The parameters are: access check method getName on resource Server and module Server. The stack trace is java.lang.Exception: Invocation and received credentials are both null


    The solution is to first configure the Servers' profile in the ASTK ide. it means that this server has security enabled and the server cannot be started by the wizard as it does not yet know the administration username as password.

    The reason why we are getting errors is that the default port being used by the IDE server profile is to use RMI so the IDE is trying to talk to the Server and authenticate over an RMI port.


    Change the Server Connection Type to SOAP and also provide a username and password id global security is turned on. In My humble opinion this is a good idea. I often see so many articles on web sites that do not provide solutions and examples with security and in the real world this is what you will have to face in the enterprise playground.

    Serve will start now.

    We now have a running server what we will do now is an action in the administration console and bring the code across to our editor.

    Right mouse click on the server to run the administration console

    Sine Global security is enabled the console will automatically switch to the SSL port. you can open the URL in a browser.


    Enable command assistance notifications
    Specifies whether to send Java Management Extensions (JMX) notifications that contain command assistance data from the administrative console. Enablement of the notifications allows integration with product tools such as the WebSphere Application Server Toolkit (AST) Jython editor. Enablement of this option is recommended for non-production environments only.


    When you do an action in the administration console it is saved in the WebSphere Administration Command view

    By double clicking the command it will be inserted into the IDE. It is a bit basic and not all the commands are tracked.


    I then used this sample code form IBM to test the ASTK to run a Jython as an administration process.

    print "getting apps..."
    apps = AdminApp.list()
    apps = apps.split(java.lang.System.getProperty('line.separator'))
    print "contains apps:\n"
    for app in apps:
    print app
    print "\nApps done.\n"

    def displayServerInfo( wsadminNode):
    wsadminSvr = AdminControl.queryNames("node="+wsadminNode+",type=Server,*")
    print "svr="+wsadminSvr
    wsadminServer = AdminControl.getAttribute(wsadminSvr,"name")
    print "ServerName="+wsadminServer
    print "wsadminMgmt="+AdminControl.getAttribute(wsadminSvr, "processType")
    wsadminSvrId = AdminControl.getConfigId(wsadminSvr)
    print "svrId="+wsadminSvrId
    if(wsadminSvrId != 0):
    print "wsadminServerType="+AdminConfig.showAttribute(wsadminSvrId, "serverType")
    wsadminState = AdminControl.getAttribute(wsadminSvr, "state")
    return wsadminState

    wsadminNode = AdminControl.getNode()
    print "NodeName="+wsadminNode

    state = displayServerInfo(wsadminNode)
    print "state="+state
    print "\nDone.\n"

    After loading all the jythn resources you will get this result

    WASX7209I: Connected to process "server1" on node T60Node03 using SOAP connector; The type of process is: UnManagedProcess
    getting apps...
    contains apps:


    Apps done.




    Well that is a basic tutorial on using the ASTK.

Get my WebSphere Application Server course here >>

Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many leading brands around the world. Steve specialises in JEE, DevOps and Thought Leadership.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide



WebSphere Categories

Other Categories