Pages

Friday, June 27, 2014

Maven support for 12.1.3 Service Bus & SOA Suite artifacts

With the 12.1.3 release of Oracle Service Bus and Oracle SOA Suite we finally can build all our soa projects with Maven. And this time we can do it natively without calling a utility like configjar or ANT from Maven .

We start by setting all the required variables like JAVA_HOME,M2_HOME and PATH

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
export M2_HOME=/Users/edwin/apache-maven-3.0.5
export PATH=${M2_HOME}/bin:${JAVA_HOME}:$PATH

Check if maven works

mvn -v 

You can also use the maven 3.0.5 version of JDeveloper 12.1.3 located at .../oracle_common/modules/org.apache.maven_3.0.5

Next step is to populate all the maven repositories

cd  .../oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3

install the maven sync plugin to the local repository

mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar -DoracleHome=/Users/edwin/Oracle/JDevMiddleware12.1.3

Deploy all the libraries to the local mvn repository

mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/Users/edwin/Oracle/JDevMiddleware12.1.3

update your local archetype catalog

mvn archetype:crawl -Dcatalog=$HOME/.m2/archetype-catalog.xml

Next steps are, to do the same but then we will fill the Nexus repository

Deploy the maven sync plugin to the nexus maven repository and we need to configure the maven settings.xml

mvn deploy:deploy-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty -DrepositoryId=internal

and do a another sync

mvn com.oracle.maven:oracle-maven-sync:push


Here is the matching maven settings.xml

  <servers>
    <server>
      <id>internal</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <name>Internal nexus Mirror of Central</name>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

  <profiles>

    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>internal</id>
          <name>internal</name>
          <url>http://localhost:8081/nexus/content/repositories/thirdparty</url>
        </repository>
      </repositories>
    </profile> 

    <profile>
      <id>oracle-maven</id>
      <properties>
        <oracleHome>/Users/edwin/Oracle/JDevMiddleware12.1.3</oracleHome>
        <serverId>internal</serverId>
        <testOnly>false</testOnly>
        <failOnError>false</failOnError>
        <overwriteParent>true</overwriteParent>
      </properties>      
    </profile> 
  </profiles>

  <activeProfiles>
     <activeProfile>nexus</activeProfile>
     <activeProfile>oracle-maven</activeProfile>
  </activeProfiles>                     



Next step is to do a describe of the soa and osb plugin

mvn help:describe -DgroupId=com.oracle.soa.plugin -DartifactId=oracle-soa-plugin -Dversion=12.1.3-0-0

with this as output

Name: Oracle SOA Maven Plugin
Description: This plugin allows users to compile, package, deploy, test and
  undeploy SOA composites.
Group Id: com.oracle.soa.plugin
Artifact Id: oracle-soa-plugin
Version: 12.1.3-0-0
Goal Prefix: oracle-soa

This plugin has 6 goals:

oracle-soa:compile
  Description: Compiles the composite. Note that 'compiling' a composite does
    not actually produce any new files, it is really a 'validation' and
    produces only output messages.

oracle-soa:deploy
  Description: To deploy a SOA composite (supports all formats SAR, MAR,
    etc.)

oracle-soa:help
  Description: Display help information on oracle-soa-plugin.
    Call mvn oracle-soa:help -Ddetail=true -Dgoal=<goal-name> to display
    parameter details.

oracle-soa:sar
  Description: Packages the composite into a SAR.

oracle-soa:test
  Description: To execute SCA Test Suites.

oracle-soa:undeploy
  Description: Undeploy a SOA composite from a SOA managed server or cluster


mvn help:describe -DgroupId=com.oracle.servicebus.plugin -DartifactId=oracle-servicebus-plugin -Dversion=12.1.3-0-0

with this as output

Name: Oracle Service Bus - Plugin
Description: (no description available)
Group Id: com.oracle.servicebus.plugin
Artifact Id: oracle-servicebus-plugin
Version: 12.1.3-0-0
Goal Prefix: servicebus

This plugin has 2 goals:

servicebus:deploy
  Description: (no description available)

servicebus:package
  Description: (no description available)



Now we are able to create a new Service Bus project from a Maven Archetype.


Provide the all the maven details


Search for the servicebus application ArcheType and select this one


Provide the required projectName of this archetype


Create the application


Now we got a Service Bus application with 3 poms, One project with sbar as package type , System project pom and a parent pom with these 2 projects


Now we can build the Service Bus project from JDeveloper by selecting the pom and right click to start for example run the package phase.

or from a terminal by using mvn package




We can do the same for a SOA Suite application and a SOA Composite.


Search for oracle-soa-application



Now we got 2 poms ( 1 is at the workspace level )  and project packaging is now a sar.


And we can also build the soa composite.




20 comments:

  1. Thanks for detailed steps. Wondering is it possible to deploy/remove MDS data using maven soa plugin ? I do not see any specific goals for it.

    ReplyDelete
    Replies
    1. Hi,

      You can use the normal soa deploy plugin, just zip the mds artifacts and deploy it just like a sar. Removal of MDS artifacts is only possible with WLST and maybe with JDeveloper MDS DB resource

      thanks

      Delete
    2. Hi Edwin,

      I'm trying to zip and deploy my mds files. I'm using the maven-assembly-plugin to zip my files. The only thing is that when I do clean pre-integration-test -DoracleServerUrl=${soaServername} -DoracleUsername=${soaUsername} -DoraclePassword=${soaPassword} -X, it builds the zip but doesn't do a deploy. It just finishes without any error. Could possibily as it can't find any sources to compile. Can you perhaps show how the pom file should look like?

      Thanks in advance

      Delete
    3. Hi Edwin,

      I am trying to deploy MDS using pom, But no luck.Can you please explain or show the pom file.

      Regards,
      Ali

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Edwin,

    Everything seems to work fine up until the point where I try to install the Nexus Repository

    "Next steps are, to do the same but then we will fill the Nexus repository

    Deploy the maven sync plugin to the nexus maven repository and we need to configure the maven settings.xml"

    At this point it all falls over

    The error is

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.704s
    [INFO] Finished at: Sun Oct 26 14:58:41 NZDT 2014
    [INFO] Final Memory: 14M/361M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not transfer artifact com.oracle.maven:oracle-maven-sync:jar:12.1.3-0-0 from/to internal (http://localhost:8081/nexus/content/repositories/thirdparty): Connection to http://localhost:8081 refused: Connection refused -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


    However when I go to this address it talks about the setting required for a proxy and I'm sitting at home without any proxies on my machine

    I can move on past this step and successfully describe both the soa and osb plugin. But when I try to create a project based on a maven archetype there is nothing there.....

    This is my first attempt at using Maven so please excuse any beginners mistakes.

    I assume the nexus repository will contain the archetypes that can be accessed from JDeveloper....

    Do you have any idea where I need to start to resolve this issues

    Thanks

    Owen

    ReplyDelete
    Replies
    1. Hi,

      I do both, to local and to nexus and in nexus I changed the third party repo to allow duplicates and snaphosts .

      and offcourse you need to provide the password of your repo in your mvn settings file . and check if the password is ok in the nexus web application

      Hope this helps



      Delete
  4. Hi Edwin

    Thanks for clear explanation. any hint on how to achieve this. we want to pass a list of composite to a parent POM file dynamic not to hardcode them. provided we have ${compositeList}=Project1,Project2,Project3 this must be passed to the POM file to create

    Project1
    Project2
    Project3


    any help will be appreciated

    Thanks
    Emmanuel

    ReplyDelete
    Replies
    1. Hi,

      maven is not flexible and everything is fixed (not dynamic) , for dynamic you should use ANT or Gradle.

      Thanks

      Delete
    2. Thanks for your reply Edwin

      Delete
    3. Agreed, Maven is not that flexible.
      In some cases using the Maven Reactor options could do the trick ( http://blog.sonatype.com/2009/10/maven-tips-and-tricks-advanced-reactor-options/#.VOopOWPVuFE ). Using them, you can specify which artifacts to build in a --pl list.
      The list is comma separated and can accept the form groupId1:artifactId1,groupId2:artifactId2 . The list can be run from the "root" of your tree and can specify artifacts deep within the Maven artifact hierarchy.
      (Beware however, that Maven Release Plugin doesn't seem to work all that well with these options.)

      Delete
  5. Hi Edwin,

    as always you take the lead :-) In the moment there is already maven.oracle.com publicly available even we are waiting for Nexus and Artifactory changes due to security realm schema presented by Oracle which are not in the moment supported, but maven itself can handle this already.

    Here are some useful links:
    https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle
    https://community.oracle.com/message/12795173#12795173

    Regarding OSB and maven I have one specific question:
    In 12c we have new additional layer called application for OSB, that is just fine, nothing new to Java world. But suppose following scenario:
    app: CommonServices
    |---> proj: CommonOSBProject
    |---> BusinessServiceAlfa
    app: RuntimeServices
    |---> proj: RuntimeOSBProject
    |---> ProxyService
    |---> ProxyServicePipeline

    Now, how to reference BusinessServiceAlfa from the ProxyServicePipeline? I can reference application in another via pom, so it appears in application resources as library(jar), or I can package one application and reference the jar file, but it is not solution. Can we in 12c cross-reference artifacts between different applications, or it is not possible and in case of referencing artifact from different OSB project the project must be part of the same application structure?

    Thanks a lot.

    Best regards,

    Ladislav

    ReplyDelete
    Replies
    1. I have been able to achieve the functionality you outline in 11.1.1.7 by doing the following:
      1. Each OSB Project is a Maven Artifact - each of these artifacts have a binary (the SBAR) and attached source (JAR with the OSB Project source code)
      2. These artifacts are deployed to the Remote Maven Repository (for example Nexus)
      3. By using Maven's dependency management we add a dependency from OSB Project A to the attached source of OSB Project B in OSB Project A's POM.
      4. Then we use a Maven Plugin to inject OSB Project B's attached source (unpacked) into a read-only part of OSB Project A's source code directory.
      This is pulling the source code treating it as an external library from the Remote Maven Repository.
      Running the plugin is done randomly by the developer ("perform refresh" of external "libs")
      5. During design time - the developer can then this way reference these artifacts (but should not modify them - they are considered external "libs")
      6. When packaging OSB Project A into SBAR and attaching source, the OSB Project B's source code is excluded

      Delete
    2. Hi Ladislav,

      I have the same problem, I need for example to call a ProxyService from another application.

      Did you find a solution ?

      Thanks,
      Mustapha

      Delete
  6. Hi Edwin, I was following the steps mentioned in the documentation.
    I installed, deployed the maven sync plugin and issued a push goal considering my archiva repository as destination.
    however, i am unable to filter soa related archetype using mvn archetype:generate -Dfilter and also in jdev i am not seeing these archetypes as you shown in the screenshots.

    do i have to do the same steps (install, deploy and push) on local repository too... please do let me know.

    Thanks
    Siva

    ReplyDelete
  7. Hi,
    there is a problem with the jar file oracle-maven-sync-12.1.3-0-0.jar?
    It says error in opening zip file. Is there a way to download an uncorrupted version of this file? Even ZIP utilities seem to be unable to open it. But I downloaded it from Oracle! :-(

    Stevie

    ReplyDelete
  8. Hi,

    Does this only support SOA projects ? Is BPM projects also supported ?

    ReplyDelete
  9. Hi,

    Does this support only SOA Projects (only BPEL) or supports also BPM projects ?

    ReplyDelete
  10. Anybody have any idea if the maven applicable for Oracle BPM?

    ReplyDelete
  11. Hi Edwin , Is it possible to deploy only the file changed instead of deploying the whole project using maven , for ex we have deployed our complete project first time and we just changed few xquery and xslt file and only interested for specific build and deployment using maven is it possible ?

    ReplyDelete