WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Problem with deploying maven ear files

    Posted 05/10/12 02:47 PM
    I've written a jython script to deploy apps to a clustered WAS7 environment.  I need to set a wildcard for the ear file name because it's created in maven and changes with each deployment (i.e. appfile1.0.0.ear, appfile1.0.1.ear, appfile1.0.2.ear).  I've defined the file path as:

    appLoc = /+file path to directory where ear file is located+/*.ear

    and am installing it with:

    AdminApp.install('[appLoc]',

    but I keep getting the following error:

    (no code object) at line 0
      File "", line 1
            appLoc = /+file path to directory where ear file is located+/*.ear
                     ^
    SyntaxError: invalid syntax
    wsadmin>wsadmin>wsadmin>

    I know it's something minute with the syntax that I'm missing but I can't for the life of me figure out what it is.  Any help would be most sincerely appreciated!

    Thanks

    Danielle


  • 2.  Problem with deploying maven ear files

    Posted 05/11/12 07:30 AM
    Did you have a look into WAS7/8 Script Libraries? 

    The following jython script has good examples, including the installation of applications in a clustered environment:
    WAS_HOME/scriptLibraries/application/V70/AdminApplication.py
    Perhaps installAppWithClusterOption is suitable for your needs, if yes, you can just call this function in your jython script. If not, Script Libraries often help understanding the jython functions.


  • 3.  Problem with deploying maven ear files

    Posted 05/11/12 01:43 PM
    Unfortunately, yes.  I've looked at the script library, I've looked at countless examples in the info center, and I've even looked at examples on independent sites I found on google.  They all give pattern matching examples for mapping EJB's, modules, and virtual hosts, but in each example they all call a specific, fully qualified ear file.  Because the name of the ear file will change with each deployment (thanks to maven/svn) I need a method that will deploy whatever ear file it finds in a specified directory to a specified cluster.

    Thanks in advance!!!


  • 4.  Problem with deploying maven ear files

    Posted 05/13/12 12:02 PM
    Hi Danielle,

       You can use the next lines in your script to get ear filename:

        import os
        path="C:\\somedirectory" # insert the path to the directory of interest here
        dirList=os.listdir(path)
        for fname in dirList:
               print fname
     

      You have another option with WebSphere (not recomended for producction environments) for deploy from a monitored directory, but in this case if your ears are versions of the same application perhaps doesn't achieve what you are looking for.

      Automatically installing applications on WebSphere Application Server v6.0 or later
       pic.dhe.ibm.com/infocenter/wasinfo/v7r0/...


      hope this helps.

    regards
     




  • 5.  Problem with deploying maven ear files

    Posted 05/16/12 12:24 PM
    Thanks so much for the info Gabriel.  I tweaked the code you suggested and it does locate the ear file:

    import os
    path="/path to directory
    dirList=os.listdir(path)
    for fname in dirList:
       if fname.endswith(".ear"):
            print 'Say hello to ' + str(fname)
       else:
            print 'Deployment directory is empty...'

    Result:

    wsadmin>Say hello to [name of file]

    The problem I'm having now is I can't get the AdminApp.install command to read fname; i.e:

    import os
    path="/path to directory"
    dirList=os.listdir(path)
    for fname in dirList:
       if fname.endswith(".ear"):
            AdminApp.install('fname', '[install options]')

    When I run it I get the following error:

    WASX7115E: Cannot read input file "/path to directory fname"

    I know its the syntax (it's always the syntax) but I can't figure out what it is.  I hate being this close and hitting a brick wall :-(

    PS.  I read the info on the monitored directory and I actually like the concept, but I know our Enterprise Security Office would crucify me if I tried to set it up.  Thanks for the info though....


  • 6.  Problem with deploying maven ear files

    Posted 05/16/12 06:06 PM
    Hi Danielle,

      Maybe permision to read directory? or file? in unix environment take in mind that is case sensitive.

      You are near to do it...the next message saying that you have instaled the application


    regards,


  • 7.  Problem with deploying maven ear files

    Posted 05/22/12 05:06 PM
    Thanks for the vote of confidence   I got the script to locate the .ear file and read it, now I just have to figure out why my pattern matching won't work for the MapModulesToServers option ...oh FYI, I had to join the file path and the contents of the directory to get it to work:

    import os
    dir = /file path to .ear file
    for fname in os.listdir(dir):
       file = os.path.join(dir, fname)
       AdminApp.install(file, '[options]')

    The saga continues.....


  • 8.  Problem with deploying maven ear files

    Posted 10/04/12 02:35 PM
    So after getting frustrated, putting it down, working on some other stuff, then coming back to it, I finally got the script to work!!

    If anyone is interested, check out my blog to see the full script....

    Thanks!