Oracle WebCenter Portal applications differ from traditional Java EE applications in that they support run-time customization. WebCenter Portal application customizations are stored in Oracle Metadata Services (MDS), which is installed in a database/file. So, while deploying the webcenter application on WLS, you need to specify the metadata repository and the partition in the repository that application will be deployed to.
As far as I know, targeting the application to MDS repository deployment is not possible using the wldeploy ant task. WLST commands can be used to target the application to MDS repository and deploy the application on WLS. So, first create a python script and then call it from the ant script.
Here is the script deploy.py -
# Below args are passed by the ant script adminUser=sys.argv[1] adminPassword=sys.argv[2] adminUrl=sys.argv[3] # Connect to WLS connect(adminUser,adminPassword,adminUrl) domainRuntime() # Stop the application def stop(): stopApplication(sys.argv[6]) # Undeploy the applciation def undeployApp(): print 'Begin undeploy' undeploy(sys.argv[6]) print 'End undeploy' # Deploy the application def deployApp(): print 'Begin deployAll' serverConfig() # Returns a handle to the MDSArchiveConfig object for the specified archive archive = getMDSArchiveConfig(fromLocation=sys.argv[4]) # Sets the connection details for the application metadata repository archive.setAppMetadataRepository(repository=sys.argv[5],partition=sys.argv[6], type=sys.argv[7], jndi=sys.argv[8]) archive.save() deploy(appName=sys.argv[6], path=sys.argv[4], targets=sys.argv[9], upload='true') print 'End deployAll' # Start the application def start(): startApplication(sys.argv[3]) # Deploy script init- First Stop the application and then undeploy. #After undeploying, deploy the application and restart try: try: stop() except: print sys.exc_info()[0] print 'Stop Done' try: undeployApp() except: print sys.exc_info()[0] print 'Undeploy Done' deployApp() start() except: print 'Unexpected error: ', sys.exc_info()[0] dumpStack() raise
Build.xml
See the target "deploy-to-dev-server" to call the above python script.
<?xml version="1.0" encoding="US-ASCII" ?> <project name="DigitalFirst" default="all" basedir="."> <property environment="env"/> <property file="build.properties"/> <taskdef name="ojdeploy" classname="oracle.jdeveloper.deploy.ant.OJDeployAntTask" uri="oraclelib:OJDeployAntTask" classpath="${oracle.jdeveloper.ant.library}"/> <!-- This target is to build ear for application --> <target name="deploy-to-ear" depends="deploy-all-projects"> <ora:ojdeploy xmlns:ora="oraclelib:OJDeployAntTask" executable="${oracle.jdeveloper.ojdeploy.path}" ora:buildscript="${oracle.jdeveloper.deploy.dir}/ojdeploy-build.xml" ora:statuslog="${oracle.jdeveloper.deploy.dir}/ojdeploy-statuslog.xml"> <ora:deploy> <ora:parameter name="workspace" value="${oracle.jdeveloper.workspace.path}"/> <ora:parameter name="profile" value="*"/> <ora:parameter name="outputfile" value="${oracle.jdeveloper.workspace.dir}/deploy/${ear.filename}"/> </ora:deploy> </ora:ojdeploy> </target> <!-- This target is to deploy the application on WLS server --> <target name="deploy-to-dev-server" > <exec executable="${oracle.wlst.path}" spawn="false" failonerror="true"> <!-- Python Script Relative Path from build.xml.In this case both are in same folder--> <arg value="deploy.py"/> <!-- Application ear Path --> <arg value="${ear.location}"/> <!-- MDS Repository Name --> <arg value="${dev.wc.mds.repository}"/> <!-- Application Name. See Project Properties -> Java EE Application --> <arg value="${application.name}"/> <!-- Repository type (DB/file) --> <arg value="${dev.wc.mds.repository.type}"/> <!-- Repository JNDI. See WLS EM console --> <arg value="${dev.wc.mds.repository.jndi}"/> <!-- WLS credential and URL --> <arg value="${dev.wls.username}"/> <arg value="${dev.wls.password}"/> <arg value="${dev.wls.adminurl}"/> <arg value="${dev.wls.cluster.name}"/> </exec> </target>
Build.properties
Below is the same build.properties file. Set the paramters based on your environment -
# Oracle Jdev Library Path variables
oracle.middleware.home=<Middleware Home> e.g C:/Oracle/Middleware
oracle.jdeveloper.home=${oracle.middleware.home}/jdeveloper
oracle.wls.home=${oracle.middleware.home}/wlserver_10.3
oracle.wlst.path=${oracle.middleware.home}/oracle_common/common/bin/wlst.cmd
oracle.jdeveloper.ant.library=${oracle.jdeveloper.home}/jdev/lib/ant-jdeveloper.jar
oracle.jdeveloper.ojdeploy.path=${oracle.jdeveloper.home}/jdev/bin/ojdeploy.exe
# Worspace related
oracle.jdeveloper.workspace.dir=<Workspace Directory> e.g C:/MyProjects/PortalApplication
oracle.jdeveloper.workspace.path=${oracle.jdeveloper.workspace.dir}/DigitalFirstApp.jws
# Deployment and ear related parameters
oracle.jdeveloper.deploy.dir=${oracle.jdeveloper.workspace.dir}/deploy
application.name=PortalApplication
ear.filename=PortalApplication.ear
ear.location=${oracle.jdeveloper.deploy.dir}/PortalApplication.ear
# Set the WLS environment related parameters
dev.wls.username=<weblogic admin username>
dev.wls.password=<weblogic admin password>
dev.wls.adminurl=<HostName>:<port>
dev.wls.cluster.name=<WLS Cluster name on which application is deployed>
# Set the MDS related parameters
dev.wc.mds.repository=<MDS Repository Name> e.g mds-CustomPortalDS
dev.wc.mds.repository.type=< It can be DB/file>
dev.wc.mds.repository.jndi=<Repository JNDI> e.g jdbc/mds/CustomPortalDS