【问题标题】:WebSphere Portal: Update/Delete a WarWebSphere Portal:更新/删除战争
【发布时间】:2011-07-11 11:01:52
【问题描述】:

我需要在 WebSphere Portal 6.0 上更新一个 portlet。我曾尝试使用 xmlaccess.bat。这是我的 DeployPortlet.xml:

<?xml version="1.0" encoding="UTF-8"?>
<request
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"
type="update"
create-oids="true">

<portal action="locate">

    <!-- The uid must match uid attribute of portlet-app in portlet.xml. -->
    <web-app action="update" active="true" uid="com.firstlinesoftware.oo.portlet.TestPortlet
       <url>file:///$server_root$/installableApps/TestPortlet.war</url>
       <!-- The uid must match uid attribute of concrete-portlet-app in portlet.xml. -->
       <portlet-app action="update" active="true" uid="TestPortlet">
          <!-- The name attribute must match content of portlet-name subtag  of concrete-portlet in portlet.xml. -->
          <portlet action="update" active="true" objectid="theIbmPortletApiPortlet" name="TestPortlet"/>
        </portlet-app>
    </web-app>

    <!-- Parent element under which the new page is inserted -->
    <content-node action="locate" objectid="parentPage" uniquename="ibm.portal.rational.portlets"/>

    <!-- The new page. 
         The contentparentref attribute must match the objectid of the parent. 
         Change the uniquename attribute to create another page. -->
    <content-node action="update" uniquename="ibm.portal.TestPortletPage"  ordinal="last" content-parentref="parentPage" active="true" allportletsallowed="false" create-type="explicit" type="page">
        <supported-markup markup="html" update="set"/>
        <localedata locale="en"><title>TestPortletPage</title></localedata>

        <component action="update" ordinal="100" type="container" orientation="H">
            <component action="update" ordinal="100" type="control">
                <!-- The portletref must match the objectid attribute of the portlet -->
                <portletinstance action="update" portletref="theIbmPortletApiPortlet"/>
            </component>
        </component>
    </content-node>

</portal>

当我第一次使用这个脚本时,一切正常。但是,当我尝试使用此脚本(无处不在 action="update")更新 portlet 时,出现异常:DuplicateAppException。

然后我尝试通过脚本删除这个portlet:

<?xml version="1.0" encoding="UTF-8"?>
<request
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"
type="update"
create-oids="true">

<!-- sample for uninstalling a web module -->
<portal action="locate">

    <!-- uid must match uid attribute of portlet-app in portlet.xml -->
   <web-app action="delete" active="true" uid="TestPortlet">
   </web-app>

</portal>
</request>

但出现警告:无法删除 portlet(没有这样的 web 模块),可能它之前已被删除。实际上这个war文件已经部署(用管理控制台检查)

有人可以帮帮我吗?

【问题讨论】:

    标签: websphere


    【解决方案1】:

    我通常不使用 xmlaccess 来执行此操作(无法告诉您如何操作)。我重新部署 portlet 应用程序(war 或 ear,取决于您如何打包它),就像在 WAS 中的任何应用程序一样。通过管理控制台或使用 wsadmin。这样做对您来说应该不是问题,因为 portlet 注册是通过重新部署来维护的。这是使用 wsadmin 部署应用程序的示例 jython 脚本。它既可以独立运行,也可以集群运行(连接到主节点)。

    import sys
    import time
    
    def wsadminToList(inStr):
            outList=[]
            if (len(inStr)>0 and inStr[0]=='[' and inStr[-1]==']'):
                    tmpList = inStr[1:-1].split() #splits space-separated lists,
            else:
                    tmpList = inStr.split("\n")   #splits for Windows or Linux
            for item in tmpList:
                    item = item.rstrip();         #removes any Windows "\r"
                    if (len(item)>0):
                            outList.append(item)
            return outList
    #endDef
    
    def installPortalApp(earFileName, appName, cellName, clusterName, installOptions):
      #--------------------------------------------------------------
      # set up globals
      #--------------------------------------------------------------
      global AdminApp
      global AdminControl
      global AdminConfig
      global Help
    
      installOptions.append('-appname')
      installOptions.append(appName)
    
      # Should we install on a cluster?
      if len(clusterName) != 0: 
        appServer = 'WebSphere:cell=' + cellName + ',cluster=' + clusterName
    
        mapModuleOptions = [[ '.*', '.*', appServer ]] 
    
        # Append additional options
        installOptions.append('-cluster')
        installOptions.append(clusterName)
        AdminApp.install(earFileName, installOptions)
        AdminConfig.save( )
    
        count = 0
    
        # This is probably not necessary 
        while not AdminApp.isAppReady(appName) and count < 10:
          count = count + 1
          print 'Waiting for app to be ready ' + count + ' of 10'
          time.sleep(10)
        #endWhile
    
        clusterId = AdminConfig.getid('/ServerCluster:' + clusterName + '/' )
        print 'clusterId' + clusterId
        clusterMembers = wsadminToList(AdminConfig.list('ClusterMember', clusterId))
    
        for member in clusterMembers:
          print 'startApplication on member ' + str(member)
          currentServer = AdminConfig.showAttribute(member, 'memberName')
          print 'currentServer ' + currentServer
          currentNodeName = AdminConfig.showAttribute(member, 'nodeName')
          print 'currentNodeName ' + currentNodeName
          query = 'cell=' + cellName + ',node=' + currentNodeName + ',type=ApplicationManager,process=' + currentServer + ',*'
          print 'query ' + query
          appMgr = AdminControl.queryNames(query )
          print appMgr
    
          Sync1 = AdminControl.completeObjectName('type=NodeSync,node=' + currentNodeName + ',*')
          print 'Sync1 ' + Sync1
          AdminControl.invoke(Sync1, 'sync')
          print 'Node synchronized. Waiting a short while for binary expansion to finish'
          time.sleep(5)
          print 'Starting application'
    
          AdminControl.invoke(appMgr, "startApplication", appName )
        #endFor
      else:
        appMgr = AdminControl.queryNames("type=ApplicationManager,*" )
        AdminApp.install(earFileName, installOptions)
        AdminConfig.save( )
        AdminControl.invoke(appMgr, "startApplication", appName )
      #endIf   
    #endDef
    
    #if (len(sys.argv) != 4 and len(sys.argv) != 5):
    #  print len(sys.argv)
    #  print "install_application_ear.py: this script requires the following parameters: ear file name, application name, cell name, install options and cluster name (optional)" 
    #  sys.exit(1)
    #endIf
    
    earFileName = sys.argv[0]
    print 'earFileName' + earFileName
    appName =  sys.argv[1]
    cellName =  sys.argv[2]
    installOptions =  eval(sys.argv[3])
    
    clusterName = ""
    if len(sys.argv) == 5:
      clusterName =  sys.argv[4]
    
    installPortalApp(earFileName, appName, cellName, clusterName, installOptions)
    

    【讨论】:

      【解决方案2】:

      让我们从头开始:您的action=delete 不起作用的原因是因为您使用不正确的uid 引用webapp。在安装过程中,您为其分配 uid com.firstlinesoftware.oo.portlet.TestPortlet,而在删除过程中,您指的是 TestPortlet。这是行不通的。

      我编写了一个重新部署 portlet 应用程序的自动化系统,它已经使用了多年,没有出现任何问题,因此您的 XMLAccess 文件中一定有问题。让我们通过它。您可以先从web-app 元素中完全删除portlet-app 子元素吗?你有什么理由需要它吗?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-10-29
        • 1970-01-01
        • 2012-06-19
        • 1970-01-01
        • 2014-08-19
        • 2013-07-20
        • 1970-01-01
        相关资源
        最近更新 更多