我需要更新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模块)可能是之前删除的。实际上已部署此war文件(使用管理控制台进行检查)
请有人帮助我吗?
答案 0 :(得分:0)
我通常不使用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)
答案 1 :(得分:0)
让我们从最后开始:你的action=delete
不起作用的原因是因为你指的是webapp
的uid不正确。在安装过程中,您可以为其指定uid com.firstlinesoftware.oo.portlet.TestPortlet
,在删除期间,您指的是TestPortlet
。这不会有用。
我编写了一个重新部署portlet应用程序的自动化系统,它已经使用多年而没有任何问题,因此XMLAccess文件中必定存在错误。让我们通过它。您可以先从portlet-app
元素中删除web-app
子元素吗?你有什么需要的吗?