7 Replies Latest reply: Feb 6, 2013 9:17 AM by 989521 RSS

    Deleting the applications using WLST

    856413
      Hi Gurus,

      I have been trying to delete the my application by using the command like this

      delete(“TestApp”,”AppDeployments”);

      But get an error every time I run this command saying

      WLSTException: ‘Error occured while performing delete : Cannot delete MBean of type AppDeployment with name TestApp. You can only delete MBeans children to the current cmo. \nTo view the children types that you can delete, use listChildTypes().’

      When i try to run this command as mentioned in the error
      listChildTypes()

      I do not see any MBeans which can help in deleting my TestApp, what am i doing wrong here? How can i delete the application?

      Thanks in advance.

      Edited by: 853410 on 27-Apr-2011 10:29
        • 1. Re: Deleting the applications using WLST
          Ravish Mody_MiddlewareMagic
          Hi,

          Please try this:
          connect(‘weblogic’,'weblogic’,'t3://10.10.10.10:9001′)
          config()
          cd (‘Applications’)
          delete (‘myApp’)
          No need to pass the second argument as you are doing .... delete(“TestApp”,”AppDeployments”)


          Thanks
          Ravish Mody
          • 2. Re: Deleting the applications using WLST
            856413
            Now as we have almost 20 applications deployed on one of our dev env and similarly we have others too so can you also help me to do the same for our environment as doing the same thing for each and every applications would be a tedious job for our team.

            Thanks
            • 3. Re: Deleting the applications using WLST
              Ravish Mody_MiddlewareMagic
              Hi,

              You can use a properties file and place the Application related informations with the Server URL details.... Then you can use a while{} Loop or a for{} loop with the same script as mentioned above.....

              For some examples of this kind of automatic WLST scripts you can find in the following link which may give you some idea on how to achieve the same goal.

              http://middlewaremagic.com/weblogic/?page_id=1492


              Thanks
              Ravish Mody
              • 4. Re: Deleting the applications using WLST
                856413
                Thank you for the suggestion.

                I have tried the way you guys do it, but I am not able to do it and getting the error which does not make sense, following is the script what I have made till now.

                script:

                from java.io import FileInputStream

                propInputStream = FileInputStream("test.properties")
                configProps = Properties()
                configProps.load(propInputStream)

                for i in 1,2:
                connect('weblogic','weblogic','t3://localhost:7001')
                config()
                cd ('Applications')
                App = configProps.get("app."+str(i))
                delete (App)
                i =i+1

                and the propertie file has this entry

                app.1=TestApp1
                app.2=TestApp2
                app.3=TestApp3

                The error which I am getting is

                Problem invoking WLST - Traceback (innermost last):
                (no code object) at line 0
                File "E:\Oracle\test\test.py", line 8
                connect('weblogic','weblogic','t3://localhost:7001')
                ^
                SyntaxError: invalid syntax

                What SyntaxError is this, I do not see any issue. Please help.

                Thanks

                Edited by: 853410 on 28-Apr-2011 10:16
                • 5. Re: Deleting the applications using WLST
                  Ravish Mody_MiddlewareMagic
                  HI,

                  The Indentation (The space before a statement) is very important in WLST because the control statements like if{} and Loops like for{} and while{} starts and ends based on the Indentation.

                  Please use the below corrected script:
                  url=t3://localhost:8001
                  username=weblogic
                  password=weblogic
                  
                  app.1=MyApp1
                  app.2=MyApp2
                  app.3=MyApp3
                  And following will be your WLST Script:
                  from java.io import FileInputStream
                  
                  propInputStream = FileInputStream("test.properties")
                  configProps = Properties()
                  configProps.load(propInputStream)
                  
                  Url = configProps.get("url")
                  print 'url=', Url
                  User = configProps.get("username")
                  print 'User=', User
                  Password = configProps.get("password")
                  print 'Password = ', Password
                  
                  connect(User,Password,Url)
                  config()
                  cd ('Applications')
                  
                  
                  for i in 1,2,3:
                       App = configProps.get("app."+str(i))
                       delete (App)
                       print 'Application ',App,' has been deleted Successfully..!!!'
                       i =i+1
                  So Now you need to just make changes in the Properties file...No need to touch anything in the WLST Script except the For Loop Count.Which is equal to the Number of applications which you want to delete ;)


                  Thanks
                  Ravish Mody
                  • 6. Re: Deleting the applications using WLST
                    856413
                    Ravish that works like charm, it took me the whole day to understand how to make it and you just made that script in few minutes. Thank you so much
                    • 7. Re: Deleting the applications using WLST
                      989521
                      Problem invoking WLST - Traceback (innermost last):
                      (no code object) at line 0
                      File "/vha/home/fusion/Deployments/SIT6/Queues/createMultipleQueues.py", line 38
                      cd('/JMSSystemResources/' + queueModule + '/JMSResource/' + queueModule + '/' + queueType + '/' + queueName)
                      ^
                      SyntaxError: invalid syntax




                      ANy Help ???