icon-arrow icon-check icon-mail icon-phone icon-facebook icon-linkedin icon-youtube icon-twitter icon-cheveron icon-download icon-instagram play close close icon-arrow-uturn icon-calendar icon-clock icon-search icon-chevron-process icon-skills icon-knowledge icon-kite icon-education icon-languages icon-tools icon-experience icon-coffee-cup
Werken bij Integration & Application Talents
Blog 13/10/2014

Fusion Middleware 12c – Embracing the power of Maven

Integration

I recently started to build a small project in JDeveloper 12c to learn how to make use of Custom Activities in an Adaptive Case Management project. The results of this  project will be posted in my next blog. When I started the project, I wanted to do it the Maven way (since JDeveloper 12c has built-in Maven support).

Being able to deploy a case as a Maven artefact requires a little initial setup. The bulk of the initial setup can also be found in a blogpost referenced in this Whiteblog from colleague Dirk Janssen. I decided that the complete setup justified a blogpost on its own. So in this post I’ll demonstrate how to deploy the (skeleton of the) case application via Maven. In the next blogpost I’ll enhance the case application with custom case activities.

Creating the application

First things first, let’s create a new BPM application CustomActivitiesDemo and add a project called CaseWithCustomActivities to the application. Choose Composite With Case Management as the project type. After you’ve created the project, you get 2 POM files for free. One aggregate POM file for the application and the POM file for the case project. Per default the groupId equals the application name (CustomActivitiesDemo). I don’t like that, so let’s change the groupId into something more structural, like nl.whitehorses.acm.

If you take a look at the generated project POM file you’ll see that it has a reference to a parent pom com.oracle.soa:sar-common. As you can see in the picture below, the curly lines indicate that the parent POM can’t be found right now. So let’s fix that, by adding the necessary artefacts to our Maven repository.

Project POM file

Project POM file

Installing the Maven artefacts

I’m developing on a Linux Mint distro and installed Maven via apt-get. I adjusted the JDeveloper preferences to make use of the Maven installation on my laptop (instead of the default embedded version):

Preferences > Maven

Preferences > Maven

 

Now we need a way to get the necessary artefacts into our local Maven repository. Oracle provides the Maven Synchronisation Plugin for this. Detailed information can be found here.

First install the plugin to your local maven repository. Open a terminal window, move to the directory where the plugin is located (<FMW12c_HOME>/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3) and issue the following command:

mvn install:install-file -DpomFile=oracle-maven-sync.12.1.3.pom -Dfile=oracle-maven-sync.12.1.3.jar

Now, this installed just the plugin. Next step is to execute the plugin in order to import the Oracle Maven artefacts, including the parent pom necessary for deploying our case composite. Issue the following command to do the magic:

mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=/path/to/oracleHome

After another BUILD SUCCESS, you can browse your local maven repository and notice that the parent pom you need for the case to deploy, is now there:

SAR project Parent POM

SAR project Parent POM

 

Now if you restart JDeveloper, and reopen the project POM file, you should notice that the curly lines are gone:

Project POM file

Project POM file

Compiling the case

Now we should be able compile the case, right? Open a terminal window, move to the directory containing the application POM file and issue the following command:

mvn clean compile

Unfortunately we’re not getting the BUILD SUCCESS we’re used to. Somewhere in the middle of the build log, you can find the reason for the build failure:
Error in getting XML input stream: oramds:/soa/shared/casemgmt/CaseAction.xsd: oracle.mds.exception.MDSException: MDS-00054: The file to be loaded oramds:/soa/shared/casemgmt/CaseAction.xsd does not exist.

So, it can’t find the necessary mds files for the project to compile. To fix this, add the following lines to the project POM file in the com.oracle.soa.plugin:oracle-soa-plugin plugin configuration section (detailed information can be found here):

<appHome>${project.basedir}/..</appHome>                   <oracleHome>${env.ORACLE_HOME}/soa</oracleHome>

Make sure the ORACLE_HOME environment variable is set and issue the mvn compile command again. Now you should see a nice BUILD SUCCESS result in your build log.

Deploying and installing the case

Now let’s fire up the embedded application server in JDeveloper and deploy the case application via Maven. For this you need to clear a few last hurdles. Deployment is tied to the pre-integration-test phase. In this phase the SCA test suites are run. For the tests to work (even if you don’t have any SCA test suites in your project), you need to add a jndi.propertiesfile to the  project (in the resources section that also contains the project POM file) with the following content:

java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://localhost:7101/soa-infra
java.naming.security.principal=weblogic
java.naming.security.credentials=welcome01
dedicated.connection=true
dedicated.rmicontext=true

Change the url, principal and credential properties to suit your embedded environment.

Add a reference to this file in the Project POM file properties section:

<jndi.properties.input>${basedir}/jndi.properties</jndi.properties.input>

Next, make sure the project is deployed with the correct server url. Move to the parent POM file in your local maven repository (.m2/repository/com/oracle/soa/sar-common/12.1.3-0-0/sar-common-12.1.3-0-0.pom) and alter the OracleServerUrl property accordingly:

<oracleServerUrl>http://localhost:7101</oracleServerUrl>

Now, let’s try to deploy our case project. Issue the following command from a terminal window (move to the directory of the application POM file first):

mvn clean install -Duser=weblogic -Dpassword=welcome01

Again make sure the username and password are correct. Unfortunately this build will fail. You’ll get an error like the one below:

[ERROR] Failed to execute goal com.oracle.soa.plugin:oracle-soa-plugin:12.1.3-0-0:deploy (default-deploy) on project CaseWithCustomActivities: file not found: /home/rgoossens/Documents/whitehorses/acm02/CustomActivitiesDemo/CaseWithCustomActivities/target/sca_CaseWithCustomActivities_rev1.0.jar -> [Help 1]

As you can see the plugin looks for a rev1.0.jar file, but the POM currently generates a 1.0-SNAPSHOT version. To fix this alter the composite.revision property (by default it’s got a value of 1.0) in the project POM file:

<composite.revision>${project.version}</composite.revision>

Now issue the mvn install command again, cross your fingers and you should get a BUILD SUCCESS now!

Reviewing the results

If you fire up your Enterprise Manager control, you’ll see that the case has been deployed:

Oracle Enterprise Manager control

Oracle Enterprise Manager control

 

The install command also added the binaries to your local Maven repository:

Maven binaries

Maven binaries

 

So that’s all there is to it. We just deployed our first case the Maven way. The example application we built in this blog can be found on GitHub right here. Enjoy!

overzicht blogs

Geen reacties

Geef jouw mening

Reactie plaatsen

Reactie toevoegen

Jouw e-mailadres wordt niet openbaar gemaakt.

Geen HTML

  • Geen HTML toegestaan.
  • Regels en alinea's worden automatisch gesplitst.
  • Web- en e-mailadressen worden automatisch naar links omgezet.

Wil je deel uitmaken van een groep gedreven en ambitieuze experts? Stuur ons jouw cv!