2011-07-11 41 views
0

我需要更新WebSphere Portal 6.0上的portlet。我試圖使用xmlaccess.bat。這裏是我的DeployPortlet.xml:WebSphere Portal:更新/刪除戰爭

<?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> 

當我使用這個劇本,第一次一切正常。但是,當我嘗試使用此腳本更新Portlet時(無論何處action="update"),都會發生異常: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> 

但警告occure:不能刪除的portlet(有沒有這樣的一個網絡模塊)也許是前面刪除。其實這個戰爭文件是部署(檢查這與管理控制檯)

任何人都可以,請幫助我嗎?

回答

0

我通常不會這樣做使用xmlaccess(不能告訴你如何)。我像WAS中的任何應用程序一樣重新部署Portlet應用程序(戰爭或耳朵,具體取決於您如何打包它)。通過管理控制檯或使用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) 
0

讓從月底開始:那是因爲你指的是webapp使用不正確的UID您action=delete不工作的原因。在安裝過程中,您將它分配給uid com.firstlinesoftware.oo.portlet.TestPortlet,並且在刪除過程中,您指的是TestPortlet。這不會奏效。

我編寫了一個重新部署portlet應用程序的自動化系統,它已經使用多年沒有問題,所以XMLAccess文件中的某些內容必須出錯。讓我們通過它。您是否可以從web-app元素中刪除portlet-app子元素?你有需要它的原因嗎?