开发者

WebSphere Portal: Update/Delete a War

I need to update a portlet on the WebSphere Portal 6.0. I have tried to use xmlaccess.bat. Here is my 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.rat开发者_开发技巧ional.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>

When I use this script for the first time everything is ok. But when I try to update the portlet with this script (everywhere action="update") the exception occure: DuplicateAppException.

Then I have tried to delete this portlet via the script:

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

but the warning occure: Can't delete the portlet(there is no such a web module) maybe it was deleted earlier. Actually this war file is deployed (checked this with an administration console)

Can anybody, please, help me?


I typically don't do this using xmlaccess (couldn't tell you how). I redeploy the portlet application (war or ear depending on how you package it) as I would any application in WAS. Either through the admin console, or using wsadmin. It shouldn't be a problem for you to do it that way since portlet registrations are maintained over redeploys. Here is a sample jython script for deploying an app using wsadmin. It works both standalone and clustered (connect to the primary node).

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)


Lets start from the end: the reason that your action=delete doesn't work is because you're referring to the webapp with an incorrect uid. During installation, you assign it the uid com.firstlinesoftware.oo.portlet.TestPortlet, and during deletion, you're referring to TestPortlet. That's not going to work out.

I programmed an automated system that redeploys portlet applications and it's been used for years with no issues, so something must be wrong in your XMLAccess file. Lets work through it. Can you start by removing the portlet-app child element altogether from the web-app element? is there a reason why you need it there?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜