WebSphere Portal:更新/删除战争

发布于 2024-11-19 10:27:15 字数 3007 浏览 3 评论 0原文

我需要更新 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>

当我第一次使用这个脚本时,一切都很好。但是,当我尝试使用此脚本更新 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>

但是出现警告:无法删除该 portlet(没有这样的 Web 模块)也许它之前被删除了。实际上这个战争文件已经部署(用管理控制台检查过)

任何人都可以帮助我吗?

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖凝香 2024-11-26 10:27:15

我通常不使用 xmlaccess 执行此操作(无法告诉您如何操作)。我像部署 WAS 中的任何应用程序一样重新部署 portlet 应用程序(war 或ear,具体取决于您打包的方式)。通过管理控制台或使用 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)

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)
浪荡不羁 2024-11-26 10:27:15

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

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

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文