Oracle Fusion Middleware 12C: Deploy the MDS using Maven

In two previous posts here and here, I demonstrated how you can setup CI for OFM 12C projects. One of the things I hadn’t figured out yet was how I could deploy the MDS using Maven. After a vague hint on the internet, Oracle’s response that this feature wasn’t officially supported yet and some trial and error I came across the solution. It is actually quite simple.

Basically it comes down to this:

  • Create a zip file of the files you want to stick into the MDS
  • Use the com.oracle.soa.plugin:oracle-soa-plugin:deploy maven goal to deploy it

That wasn’t that hard as you can see :) Let’s go into a bit more detail. You can use a command line to create the zip or use the maven-assembly-plugin to give you a bit more flexibility. I used the last option because I wanted to filter certain files. Within my Jenkins job, I checked out my MDS files and zipped them using the package goal into a file called sca-MDS_rev1.0.jar. Look in the plugin section in the pom file down below to see about the configuration of the assembly plugin. The pom file is just a copy of a normal soa composite project.

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <!--
           This POM was automatically generated during SOA project creation.           
           This POM relates to this SOA Composite, i.e. the one in this same directory.
           There is another POM in the SOA Application directory which handles
           the whole SOA Application, which may contain additional projects. 
        -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>nl.cvgz</groupId>
    <artifactId>MDS</artifactId>
    <version>1.0</version>
    <packaging>sar</packaging>
    
    <!--
           The parent points to the common SOA parent POM.  That is a special POM that is
           shipped by Oracle as a point of customization (only). You can add default values
           for properties like serverUrl, etc. to the SOA common parent POM, so that you
           do not have to specify them over and over in every project POM.
    --> 
    <parent>
        <groupId>com.oracle.soa</groupId>
        <artifactId>sar-common</artifactId>
        <version>12.1.3-0-0</version>
    </parent>
    
    <properties>
        <!-- These parameters are used by the compile goal -->
        <scac.input.dir>${project.basedir}\SOA/</scac.input.dir>
        <scac.output.dir>${project.basedir}/target</scac.output.dir>
        <scac.input>${scac.input.dir}/composite.xml</scac.input>
        <scac.output>${scac.output.dir}/out.xml</scac.output>
        <scac.error>${scac.output.dir}/error.txt</scac.error>
        <scac.displayLevel>1</scac.displayLevel>
        <!-- if you are using a config plan, uncomment the following line and update to point
             to your config plan -->
        <!--<configplan>${scac.input.dir}/configplan.xml</configplan>-->
        
        <!-- These parameters are used by the deploy and undeploy goals --> 
        <composite.name>${project.artifactId}</composite.name>
        <composite.revision>${project.version}</composite.revision>
        <composite.partition>default</composite.partition>        
        <serverUrl>${oracleServerUrl}</serverUrl>        
        <user>${oracleUsername}</user>
        <password>${oraclePassword}</password>
        <overwrite>true</overwrite>
        <forceDefault>true</forceDefault>
        <regenerateRulebase>false</regenerateRulebase>
        <keepInstancesOnRedeploy>false</keepInstancesOnRedeploy>
        
        <!-- These parameters are used by the test goal 
         if you are using the sca-test (test) goal, you need to uncomment the following
             line and point it to your jndi.properties file. --> 
             
        <!--<jndi.properties.input>UNDEFINED</jndi.properties.input>-->
        <scatest.result>${scac.output.dir}/testResult</scatest.result>
        <!--  input is the name of the composite to run test suties against -->
        <input>${project.artifactId}</input>
        
        <!--<scac.ant.buildfile>${env.MW_HOME}/soa/bin/ant-sca-compile.xml</scac.ant.buildfile>
        <sca.ant.testfile>${env.MW_HOME}/soa/bin/ant-sca-test.xml</sca.ant.testfile>
        -->
        
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.oracle.soa.plugin</groupId>
                <artifactId>oracle-soa-plugin</artifactId>
                <version>12.1.3-0-0</version>
                <configuration>
                    <compositeName>${project.artifactId}</compositeName>
                    <composite>${scac.input}</composite>
                    <sarLocation>${scac.output.dir}/sca-${project.artifactId}_rev${composite.revision}.jar</sarLocation>
                    <serverUrl>${serverUrl}</serverUrl>
                    <user>${user}</user>
                    <password>${password}</password>
                    <!-- Note: compositeRevision is needed to package, revision is needed to undeploy -->
                    <compositeRevision>${composite.revision}</compositeRevision>
                    <revision>${composite.revision}</revision>
                    <scacInputDir>${scac.input.dir}</scacInputDir>                    
                    <input>${input}</input> 
                </configuration>
                <!-- extensions=true is needed to use the custom sar packaging type -->
                <extensions>true</extensions>
            </plugin>
	    <!-- plugin om te zorgen dat de apps directory gezipt wordt voor de MDS -->
	    <plugin>
			<artifactId>maven-assembly-plugin</artifactId>
			<version>2.4.1</version>
			<configuration>
				<finalName>sca</finalName>
				<descriptors>
					<descriptor>zip-assembly-descriptor.xml</descriptor>
				</descriptors>
			</configuration>
			<executions>
				<execution>
					<id>make-assembly</id>
					<phase>package</phase>
					<goals>
						<goal>single</goal>
					</goals>
				</execution>
		     </executions>
		</plugin>
        </plugins>
    </build>
</project>

Here is the zip-assembly-descriptor.xml

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>MDS_rev1.0</id>
  <baseDirectory>/</baseDirectory>
  <formats>
    <format>jar</format>
  </formats>
  <fileSets>
	<fileSet>
      <directory>../../../GedeeldeObjecten/apps</directory>
      <outputDirectory>/</outputDirectory>
	  <includes>
        <include>services/**</include>
		<include>dvm/**</include>
      </includes>
    </fileSet>
	
  </fileSets>
</assembly>

As you can see I create a jar which includes my services and dvm directory. One thing to take in account is that you don’t need an apps directory in the zip. At first I created an apps directory as a top directory but when I deployed this, my MDS had a apps/apps structure so I removed this. My sca-MDS_rev1.0.jar has the following structure:

-dvm
   -MyDVM.dvm
-services
   -HelloService_1.0
       -HelloService_1.0.xsd
       -HelloService_1.0.wsdl

The only now left to do is to point the ${scac.output.dir}/sca-${project.artifactId}_rev${composite.revision}.jar in the pom to the right location where your jar file is located.

When you run the com.oracle.soa.plugin:oracle-soa-plugin:deploy goal, maven will deploy you MDS jar like this:

[INFO] --- maven-assembly-plugin:2.4.1:single (make-assembly) @ MDS ---
[INFO] Reading assembly descriptor: zip-assembly-descriptor.xml
[INFO] Building jar: D:\tomcatfiles\.jenkins\jobs\SOA - MDS\workspace\MDS\soa\MDS\target\sca-MDS_rev1.0.jar
[INFO] 
[INFO] --- oracle-soa-plugin:12.1.3-0-0:deploy (default-cli) @ MDS ---
[INFO] ------------------------------------------------------------------------
[INFO] ORACLE SOA MAVEN PLUGIN - DEPLOY COMPOSITE
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] setting user/password..., user=weblogic
Processing sar=D:\tomcatfiles\.jenkins\jobs\SOA - MDS\workspace\MDS\soa\MDS/target/sca-MDS_rev1.0.jar
Adding shared data file - D:\tomcatfiles\.jenkins\jobs\SOA - MDS\workspace\MDS\soa\MDS\target\sca-MDS_rev1.0.jar
INFO: Creating HTTP connection to host:MY_SERVER, port:7010
INFO: Received HTTP response from the server, response code=200
---->Deploying composite success.
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.313 s

[INFO] Finished at: 2015-05-23T02:59:22+02:00
[INFO] Final Memory: 36M/360M
[INFO] ------------------------------------------------------------------------
[workspace] $ cmd /c call D:\ProgramFiles\Apache\Tomcat8.0\temp\hudson4288153212971789360.bat
channel stopped

4 thoughts on “Oracle Fusion Middleware 12C: Deploy the MDS using Maven

  1. Pingback: SOA & BPM Community Newsletter June 2015 | SOA Community Blog

  2. Pingback: Fusion Middleware 12C: Deploy the MDS using Maven by Hugo Hendriks | SOA Community Blog

  3. This step is not clear. could you please explain
    ${scac.output.dir}/sca-${project.artifactId}_rev${composite.revision}.jar in the pom to the right location where your jar file is located.

    • If you look at the properties in the pom file, you can see that scac.output.dir equals ${project.basedir}/target. So it basically points to the target directory where your compiled jar has to be created. Next you have to define a name for the jar. That is done by stating sca-${project.artifactId}_rev${composite.revision}.jar. This creates a name sca-MDS_rev1.0.jar in my case as my project.artifactId = MDS and composite.revision = 1.0.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>