WebSphere Application Server & Liberty

 View Only
  • 1.  JDBCProviderManagement listDatasources syntax in online docs

    Posted Tue July 05, 2022 01:01 PM
    Hello,

    I am writing some scripts to create and delete resources in WebSphere Application Server 9.0.5 and am curious about the syntax on this page

    JDBCProviderManagement command group for AdminTask object

    In particular this example on that page :-

    Using Jython string:
    AdminTask.listDatasources('[-scope Cell=my02Cell]')
    vs.

    Using Jython list:
    AdminTask.listDatasources('-scope', 'Cell=my02Cell')
    I tried both commands with a Cluster called cluster1 and the format for the Jython list does not work. The first one (Jython string) works fine but the second (Jython list) does not:-

    [wsphere@host1 profile_creation_Linux]$ /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh
    WASX7209I: Connected to process "dmgr" on node host1CellManager01 using SOAP connector;  The type of process is: DeploymentManager
    WASX7031I: For help, enter: "print Help.help()"
    wsadmin>AdminTask.listDatasources('[-scope Cluster=cluster1]')
    u'"Default Datasource(cells/host1Cell01/clusters/cluster1|resources.xml#DataSource_1656872291833)"'
    wsadmin>
    wsadmin>
    wsadmin>AdminTask.listDatasources('-scope', 'Cluster=cluster1')
    WASX7015E: Exception running command: "AdminTask.listDatasources('-scope', 'Cluster=cluster1')"; exception information:
    com.ibm.bsf.BSFException: exception from Jython:
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
    TypeError: listDatasources(): expected 0-1 args; got 2
    
    wsadmin>​

    Is there a typo on that page (comma and quotes should not be there delimiting the scope value from the -scope ) or have I translated the example which was for a Cell incorrectly for obtaining a list of datasources in a Cluster using the Jython list format? This works so I am thinking that its a mistake in the example on that page:-

    wsadmin>AdminTask.listDatasources('-scope Cluster=cluster1')
    u'"Default Datasource(cells/host1Cell01/clusters/cluster1|resources.xml#DataSource_1656872291833)"'
    ​

    Regards

    Rod


    ------------------------------
    Rod Allen
    ------------------------------


  • 2.  RE: JDBCProviderManagement listDatasources syntax in online docs

    Posted Wed July 06, 2022 01:57 AM

    Hi Rod, this looks like a typo in the documentation as for Jython list, the brackets [] in the listDatasources command are missing.

    The correct syntax should be something like: AdminTask.listDatasources(['-scope', 'Cell=my02Cell']).


    BTW: If you want to create scripts, my recommendation would be to use the command assistant.
    https://www.ibm.com/docs/en/was-nd/9.0.5?topic=console-accessing-command-assistance-from-administrative
    as this provides the option to get the jython commands for the steps you are doing in the admin console.

    Hope that helps.

    Lars



    ------------------------------
    Lars Besselmann
    Integration Technical Specialist, IBM Technology Sales, EMEA
    IBM
    Düsseldorf
    ------------------------------



  • 3.  RE: JDBCProviderManagement listDatasources syntax in online docs

    Posted Wed July 06, 2022 06:14 AM
    Edited by Rod Allen Wed July 06, 2022 08:09 AM
    Thanks for your feedback Lars. I can see that the document has been updated now. Thanks also for reminding me about the command assistant, I have been using that to build some of the tricky syntax and its great :)

    Regards

    Rod

    ------------------------------
    Rod Allen
    ------------------------------



  • 4.  RE: JDBCProviderManagement listDatasources syntax in online docs

    Posted Wed July 06, 2022 02:37 AM
    Edited by Brian S Paskin Wed July 06, 2022 02:37 AM
    Hi, you need to tell the wsadmin script you want to use Jython.
     /opt/IBM/WebSphere/AppServer/bin/wsadmin.sh​ -lang jython


    Though, as mentioned above, it looks like an error in the docs.

    Brian



    ------------------------------
    Brian S Paskin
    Sr. Cloud Engineer
    IBM Cloud Engineering
    ------------------------------



  • 5.  RE: JDBCProviderManagement listDatasources syntax in online docs

    Posted Wed July 06, 2022 06:17 AM
    Hi Brian,

    Thanks for the feedback and good point about specifying the lang as although it defaults to jython in WAS 9.0.5 it still defaults to jacl in 8.5.5 so I realise that its not always safe to assume it will use Jython. I will adapt my scripts to include -lang jython as a safeguard.

    Thanks

    Rod

    ------------------------------
    Rod Allen
    ------------------------------