Forum Stats

  • 3,837,327 Users
  • 2,262,247 Discussions
  • 7,900,253 Comments

Discussions

Undeploy projects in OSB 11gR1 with ant

869075
869075 Member Posts: 2
edited Feb 9, 2012 4:59PM in SOA Suite Discusssions
Hello,

I'm trying to undeploy some projects with ant-scripts. I tried everything, but I didn't find a way to solve the problem.
To be clear I mean the projects, which you can see in then sbconsole and not the deployments.
I want to do a silent installation of the OSB and I don't want to use additional software like eclipse or something.

Has anyone tried it? Can you please help me?

Thanks in advance
Ralf
Tagged:

Answers

  • Anuj Dwivedi--Oracle
    Anuj Dwivedi--Oracle Member Posts: 7,077 Employee
    I think with WLST and ant it should be possible but do not have any existing sample/doc. BTW, why can't you simply delete the project using sbconsole?

    Regards,
    Anuj
  • ferp
    ferp Member Posts: 65
    Hi,

    you can do it using a WLST simple script. Below an extract from one that I've used to remove an OSB project:

    def deletePrj():
    projectName = '...'
    projectRef = Ref(Ref.PROJECT_REF, Ref.DOMAIN, projectName)
    print '#### removing OSB project: ' + projectName
    if ALSBConfigurationMBean.exists(projectRef):
    ALSBConfigurationMBean.delete(Collections.singleton(projectRef))
    else:
    failed = 'OSB project <' + projectName + '> does not exist'
    raise Failure(failed)
    print '#### removed project: ' + projectName
    print

    Best regards
    ferp
    ferp
  • 869075
    869075 Member Posts: 2
    Hello ferp,

    Thank you! Your solution rocks:
    if ALSBConfigurationMBean.exists(projectRef):
    ALSBConfigurationMBean.delete(Collections.singleton(projectRef))
    print " Deleting project:", projectName
    else:
    failed = 'project does not exist'

    I only had a problem with the activateSession .

    Ralf
  • 652331
    652331 Member Posts: 32
    I have tried this script and for some bizarre reason I get a

    TypeError: exists(): expected 2 args; got 1

    error for the call to ALSBConfigurationMBean.exists(projectRef).

    Also, this error appears for the delete() method if I remove the conditional check.

    All the Javadocs point to only 1 argument, so I am pretty much stumped.

    Any ideas would be tryuly helpful. Source (abridged version) below.


    from java.util import Collections

    from com.bea.wli.sb.util import Refs
    from com.bea.wli.config import Ref
    from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean

    import sys

    #=======================================================================================
    # Entry function to deploy project configuration and resources
    # into a ALSB domain
    #=======================================================================================

    def undeployFromALSBDomain():
    try:
    projectName = project
    sessionName = createSessionName()
    print 'Created session', sessionName
    SessionMBean = getSessionManagementMBean(sessionName)
    print "SessionMBean started session"
    print "Trying to remove " + projectName
    projectRef = Ref(Ref.PROJECT_REF, Ref.DOMAIN, projectName)
    print "#### removing OSB project: " + projectName

    if ALSBConfigurationMBean.exists(projectRef):
    ALSBConfigurationMBean.delete(Collections.singleton(projectRef))
    SessionMBean.activateSession(sessionName, "Complete project removal with customization using wlst")
    else:
    failed = "OSB project <" + projectName + "> does not exist"
    raise Failure(failed)
    print "#### removed project: " + projectName
    print
    except:
    print "Unexpected error:", sys.exc_info()[0]
    if SessionMBean != None:
    SessionMBean.discardSession(sessionName)
    print "Session discarded"
    raise
  • 652331
    652331 Member Posts: 32
    Ok, so I got a bit further by adding


    ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")

    before the if ALSBConfigurationMBean.exists(projectRef) statement.

    Next issues is that my delete says
    com.bea.wli.config.component.DeleteException: Cannot delete resource outside of a session

    even though I create a session immediately before I do the delete as shown below.


    SessionMBean = findService("SessionManagement", "com.bea.wli.sb.management.configuration.SessionManagementMBean")
    ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
    if ALSBConfigurationMBean.exists(projectRef):
    SessionMBean.createSession(sessionName)
    ALSBConfigurationMBean.delete(Collections.singleton(projectRef))
    SessionMBean.activateSession(sessionName, "Complete project removal with customization using wlst")

    Any ideas?

    Cheers

    Matt
  • 652331
    652331 Member Posts: 32
    Ok, solved it now by pieceing together various bits and pieces on the internet.

    It appears when getting the ALSBConfigurationMBean you have to add the session name onto the service name to find the correct bean.

    Oracle, please document the deploy/undeploy process using Ant with WLST instead of making people hunt around for stuff, it is very time consuming and unnecessary.

    The undeploy code is as follows and works.


    try:
    projectName = project
    sessionName = createSessionName()
    print "Trying to remove " + projectName
    projectRef = Ref(Ref.PROJECT_REF, Ref.DOMAIN, projectName)

    SessionMBean = findService("SessionManagement", "com.bea.wli.sb.management.configuration.SessionManagementMBean")
    print "SessionMBean started session"
    SessionMBean.createSession(sessionName)
    print 'Created session<', sessionName, '>'
    ALSBConfigurationMBean = findService("ALSBConfiguration." + sessionName.toString(), "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
    if ALSBConfigurationMBean.exists(projectRef):
    print "#### removing OSB project: " + projectName
    ALSBConfigurationMBean.delete(Collections.singleton(projectRef))
    SessionMBean.activateSession(sessionName, "Complete project removal with customization using wlst")
    else:
    print "OSB project <" + projectName + "> does not exist"
    failed = "OSB project <" + projectName + "> does not exist"
    raise Failure(failed)
    print "#### removed project: " + projectName
    print
    except:
    print "Error whilst removing project:", sys.exc_info()[0]
    discardSession(SessionMBean, sessionName)
    raise

    def discardSession(SessionMBean, sessionName):
    if SessionMBean != None:
    if SessionMBean.sessionExists(sessionName):
    SessionMBean.discardSession(sessionName)
    print "Session discarded"
This discussion has been closed.