Pages

Sunday, October 7, 2012

Build and Deploy OSB projects with Maven

2 years ago I already did the same with ANT and now I migrated these scripts to Maven. These Maven poms can still do the same like my ANT scripts.
  • Build and deploy an OSB OEPE workplace
  • Build one OSB project.
  • Export OSB projects from an OSB server and generate a customization plan.
Here you can find my code https://github.com/biemond/soa_tools/tree/master/maven_osb_ps5 or the PS6 version https://github.com/biemond/soa_tools/tree/master/maven_osb_ps6
or with the new PS6 configjar tool which can create offline OSB exports without OEPE http://biemond.blogspot.nl/2013/04/offline-oracle-service-bus.html 

Also the readme contains some examples how to this from Java without the help of Maven or Ant.

I based my scripts on the following software and folders

My Environment Oracle OSB PS5 or 11.1.1.6 with Maven 3.0.4

JVM                         = JDK 1.7_07 x64
Middleware home      = /opt/oracle/wls/wls11g
OSB & Oracle home = /opt/oracle/wls/wls11g/Oracle_OSB1
WebLogic home       = /opt/oracle/wls/wls11g/wlserver_10.3
Oepe home               = /opt/oracle/wls/wls11g/oepe11.1.1.8

My Maven settings.xml


run . osb.sh to set all the Maven, Java variables.

To build a project or the whole OEPE workspace use this
mvn package

To deploy or export an existing OSB server use this target-env=dev so it uses the right Maven profile for the WebLogic Settings
mvn deploy -Dtarget-env=dev

Prepare a release
mvn release:prepare

Perform a release
mvn release:perform -Dtarget-env=dev 
-DconnectionUrl=scm:git:git@github.com:biemond/soa_tools.git



the pom.xml in the Maven_osb_ps5 folder build the whole source folder workspace, this generates a jar in the export folder with the same name as your pom definition.

the pom.xml in the Maven_osb_ps5/source/ReliableMessageWS and Maven_osb_ps5/source/XSDvalidation folder build only this project and generate a jar in the export folder with the same name as your pom definition.

the pom.xml in the Maven_osb_ps5/export folder export everything from the OSB server and puts the jar in the import folder.

Here is an example of a pom which build and deploys the whole OSB OEPE workspace.
This pom has the following plugins

  • exec-maven-plugin for building the OSB jar and deploy the jar to the OSB server, 
  • maven-assembly-plugin for adding the OSB jar as maven artifact 
  • maven-release-plugin for OSB releases. 

And here the assembly to add the generated OSB jar to Maven artifact

14 comments:

  1. Is it working under 11.1.1.5?

    ReplyDelete
    Replies
    1. Hi,

      It should work also on PS3, just lookup the right classpath jar versions.

      thanks

      Delete
  2. Thank you for this article so interesting.

    The use of maven is a breakthrough for OSB project developers

    Regards

    ReplyDelete
  3. Hi Edwin,

    Do you know if it's possible to export subprojects (a especific folder of a project)?

    And another question, when I export a project using eclipse IDE takes seconds, but if you export a project with the java command (equinox.launcher...) it takes much more? is it possible to export as eclipse does?

    Thanks in advance

    ReplyDelete
    Replies
    1. Hi,

      nop, only whole workspace or one or more OSB projects. And indeed it takes more but starting up eclipse, svn update etc also takes times and you can automate it now with Hudson

      thanks

      Delete
    2. Running this under windows i am running into the following

      [INFO] --- exec-maven-plugin:1.2.1:exec (buildAllFromOEPE) @ osb.all.projects ---
      java.lang.NoClassDefFoundError: org/eclipse/equinox/launcher/Main
      Caused by: java.lang.ClassNotFoundException: org.eclipse.equinox.launcher.Main
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      Could not find the main class: org.eclipse.equinox.launcher.Main. Program will exit.

      Any pointers please

      Delete
    3. Hi,

      check the wls,osb and oepe path in the maven settings and if these jars in the pom exactly matches with your env.

      thanks

      ${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
      ${osb.home}/modules/com.bea.common.configfwk_1.6.0.0.jar
      ${osb.home}/modules/com.bea.core.xml.xmlbeans_2.2.0.0_2-5-1.jar
      ${osb.home}/lib/alsb.jar
      ${osb.home}/lib/sb-kernel-wls.jar
      ${osb.home}/lib/sb-kernel-impl.jar
      ${osb.home}/lib/sb-kernel-api.jar
      ${weblogic.home}/server/lib/weblogic.jar
      ${weblogic.home}/server/lib/wls-api.jar

      Delete
    4. We are using maven plugin to build OSB project separtely, it works fine but we have few issues
      My Environment details
      OSB version- 11.1.1.6
      Maven - 3.0.4
      OEPE - oepe11.1.1.8

      We have few issues
      1. When we build the project by executing mvn package it generates below files in Project folder
      alsbdebug.xml
      configfwkdebug.xml
      security folder with SerializedSystemIni.dat file
      Exported jar file also has these files, is there a way to avoid these files
      When we use the ant version of script these files were not generated, only when we use Maven plugin with command line arguments it is generating these files.

      2. First time it works fine and for the second time when we run the same command to build the project it gives "setting transaction 12 as rollback only" and hangs and in some cases it gives below error
      "Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources."
      When we delete .metadata folder it works fine, whether every time we need to delete the .metadata folder before running the script.

      3. It takes longer time (in some cases more that 15 minutes for one project) to build and generate the project sbconfig jar, how to optimize it which process is taking more time

      Delete
    5. Hi,

      you can control the location of the osb files by changing the workingDirectory ${project.basedir}/../../ in the parent pom.

      the .metadata folder is a known issue, can you try my maven build if this is a server , environment issue or something in your osb workspace.

      can you try this on a windows or from a x windows env.

      By the way the new configtool of PS6 is fast,so flexible , no need for eclipse and works great with maven. Here I also added some extra pom propeties to control the build location.

      Thanks

      Thanks

      Delete
    6. Thanks, I am able to control the osb files by changing the working directory.
      I am running this in Windows only.
      Our requirement is to build each OSB project separately, first time when we build it works fine without any errors, next time on wards it gives below error but still it generates the sbconfig.jar
      How we can avoid this error

      ****************************************************************************************************************
      Synchronizing "OSB Configuration"...
      <Setting trans
      action '10' as rollback only. Rollback reason:
      java.lang.NullPointerException
      at com.bea.wli.config.task.impl.GetSnapshotTask.getCurrentSnapshot(GetSn
      apshotTask.java:166)
      at com.bea.wli.config.task.impl.GetSnapshotTask._execute(GetSnapshotTask
      .java:97)
      at com.bea.wli.config.task.impl.GetSnapshotTask$2._execute(GetSnapshotTa
      sk.java:229)
      at com.bea.wli.config.task.impl.SessionedTask$1.execute(SessionedTask.ja
      va:233)
      at com.bea.wli.config.transaction.TransactionalTask._doExecute(Transacti
      onalTask.java:217)
      at com.bea.wli.config.transaction.TransactionalTask._doExecuteWithRetry(
      TransactionalTask.java:162)
      at com.bea.wli.config.transaction.TransactionalTask.doExecute(Transactio
      nalTask.java:142)
      at com.bea.wli.config.task.impl.SessionedTask.doExecute(SessionedTask.ja
      va:236)
      at com.bea.wli.config.task.impl.SessionedTask.doExecute(SessionedTask.ja
      va:191)
      at com.bea.wli.config.task.impl.GetSnapshotTask.getDigestSnapshot(GetSna
      pshotTask.java:245)
      at com.bea.wli.config.task.impl.GetSnapshotTask.getDigestSnapshot(GetSna
      pshotTask.java:210)
      at com.bea.alsb.core.internal.config.synchronize.DeltaSynchronizer.run(U
      nknown Source)
      at com.bea.alsb.core.internal.config.synchronize.DeltaSynchronizer.run(U
      nknown Source)
      at com.bea.alsb.core.internal.config.synchronize.SynchronizerService.run


      ***************************************************************************************************************

      Delete
    7. Hi,

      Do you check in your sources in svn like the .metadata folder or do not clean before. this way you always get a fresh install and maybe you can check the changes after the first run.

      Thanks

      Delete
  4. Hi,

    I uploaded the OSB maven PS6 or 11.1.1.7 version to the soa_tools github repos
    https://github.com/biemond/soa_tools/tree/master/maven_osb_ps6


    ReplyDelete
    Replies
    1. Hi All,

      I made a new blogpost about the new OSB PS6 offline configjar tool ( made 2 versions , one with a shell script and how to do this in maven.
      http://biemond.blogspot.nl/2013/04/offline-oracle-service-bus.html

      Thanks

      Delete