Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts

Wednesday, September 11, 2013

Maven Archetype for OSB Project

This is a maven archetype (osb-archetype-blog.zip) for creating an OSB project that Eclipse and Maven can share.

Two things to note about the archetype:

1. I have a local OSB 11.1.1.6 installed, so the POM references to some jar files are 11.1.1.6 specific. You may need to adjust it.
2. If you just want to create setup an OSB project for Eclipse, you can remove the entire plugin section in the POM file. But then, there is no point of using Maven to create the project. The "value" of Maven in this case is it allows you to build OSB jar from the command line, and also allows you to use Eclipse to work on the project.

To place the archetype in your local repository, you can just run "mvn install" after unzip the file.

To create a new OSB project, run something like "mvn archetype:generate -DgroupId=myOsbGrp -DartifactId=myOsbProj", then select the new archetype. For me the # is 832, yours can be different depends on how many archetypes you already have in your repository.

Once the project is created, it will have a folder structure like below:

myOsbProj
│   pom.xml

├───src
│   └───main
│       └───resources
│           ├───OSBConfiguration
│           │   │   .project
│           │   │
│           │   └───.settings
│           │           com.bea.alsb.core.prefs
│           │           org.eclipse.wst.common.component
│           │           org.eclipse.wst.common.project.facet.core.xml
│           │           org.eclipse.wst.validation.prefs
│           │
│           └───OSBProject
│               │   .project
│               │
│               ├───.settings
│               │       org.eclipse.wst.common.component
│               │       org.eclipse.wst.common.project.facet.core.xml
│               │       org.eclipse.wst.validation.prefs
│               │
│               ├───BusinessServices
│               │       BusinessService1.biz
│               │
│               ├───ProxyServices
│               │       ProxyService1.proxy
│               │
│               └───Resources
│                       helloworld.wsdl

From here, you can use Eclipse to import the existing project (pick "main/resources" directory, Eclipse will sort out the rest). You can check in/check out the source to SVN.

The new pom.xml file allows you to build the OSB project from the command line without using Eclipse, therefore make the automated build (CI) possible.

The archetype can be further improved to add deployment (deploying the OSB jar to a server). I'm a beginner of Maven. That would be a future project at some point.

Wednesday, May 29, 2013

maven/ant/java export osb config jar from the source files

Maven and ant call eclipse plugin "org.eclipse.equinox.launcher" to export the osb config jar file.

Our project default uses OEPE 11.1.1.4. But I have OEPE 11.1.1.6. I had to adjust a few lines to make it work for me. Here is my final result:

<execution>
<id>compileOSB</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="makeosbjar">
<path id="library.osb">
<fileset dir="${OSB_HOME}/modules">
<include name="com.bea.common.configfwk_1.6.0.0.jar" />
<include name="com.bea.core.xml.xmlbeans_2.2.0.0_2-5-1.jar" />
</fileset>
<fileset dir="${MW_HOME}/wlserver_10.3/server/lib">
<include name="weblogic.jar" />
</fileset>
<fileset dir="${OSB_HOME}/lib">
<include name="alsb.jar" />
</fileset>
</path>
<java dir="${OEPE_PLUGINS_HOME}/.." jar="${OEPE_PLUGINS_HOME}/org.eclipse.equinox.launcher_1.2.0.v20110502.jar" classpathref="library.osb" fork="true" failonerror="true" maxmemory="768m">
<!--jvmarg line="-d64" /-->
<jvmarg line="-XX:MaxPermSize=256m" />
<arg line="-application com.bea.alsb.core.ConfigExport" />
<arg line="-data ${project.build.directory}/classes" />
<arg line="-configProject MyOSBConfiguration" />
<arg line="-configSubProjects ${osb.config.project}" />
<arg line="-configJar ${project.build.directory}/${project.artifactId}-${project.version}.jar" />
<sysproperty key="weblogic.home" value="${MW_HOME}/wlserver_10.3" />
<sysproperty key="osb.home" value="${OSB_HOME}" />
<sysproperty key="middleware.home" value="${MW_HOME}"/>
</java>
</target>
</configuration>
</execution>

i have highlighted the changes i made. If you have a different OEPE version, you need to find your corresponding jars for these:

    com.bea.common.configfwk
    com.bea.core.xml.xmlbeans
    org.eclipse.equinox.launcher_1.2.0.v20110502.jar

Additionally, I have Java 1.6.0_31. Although it's 64 bit version, it doesn't support "-d64" option. So i took that out. However, the most important parameter i added in is <sysproperty key="middleware.home" value="${MW_HOME}"/>. That resolved that perplexing error message:
...
Caused by: java.lang.NoClassDefFoundError: org/apache/xmlbeans/SchemaTypeLoader
...

==== post note:

Using java directly:
set classpath=C:\Oracle\Middleware\Oracle_OSB1\modules\com.bea.common.configfwk_1.6.0.0.jar;C:\Oracle\Middleware\Oracle_OSB1\modules\com.bea.core.xml.xmlbeans_2.2.0.0_2-5-1.jar;C:\Oracle\Middleware\wlserver_10.3\server\lib\weblogic.jar;C:\Oracle\Middleware\Oracle_OSB1\lib\alsb.jar

set jvmarg=-XX:MaxPermSize=256m -Xmx768m -Dweblogic.home=C:\Oracle\Middleware/wlserver_10.3 -Dosb.home=C:\Oracle\Middleware\Oracle_OSB1 -Dmiddleware.home=C:\Oracle\Middleware

set java_options=-application com.bea.alsb.core.ConfigExport -data D:\proj\osbproj1 -configProject "OSB Configuration" -configSubProjects "OSBProject" -configJar "sbconfig.jar"

java %jvmarg% -jar C:\Oracle\Middleware\oepe11118\plugins\org.eclipse.equinox.launcher_1.2.0.v20110502.jar %java_options%

Here is a full expansion of java command line:

java -XX:MaxPermSize=256m  -Xmx768m  -Dweblogic.home=C:\Oracle\Middleware/wlserver_10.3  -Dosb.home=C:\Oracle\Middleware\Oracle_OSB1  -Dmiddleware.home=C:\Oracle\Middleware  -classpath  C:\Oracle\Middleware\Oracle_OSB1\modules\com.bea.common.configfwk_1.6.0.0.jar;C:\Oracle\Middleware\Oracle_OSB1\modules\com.bea.core.xml.xmlbeans_2.2.0.0_2-5-1.jar;C:\Oracle\Middleware\wlserver_10.3\server\lib\weblogic.jar;C:\Oracle\Middleware\Oracle_OSB1\lib\alsb.jar  -jar  C:\Oracle\Middleware\oepe11118\plugins\org.eclipse.equinox.launcher_1.2.0.v20110502.jar  -application  com.bea.alsb.core.ConfigExport  -data  D:\proj\osbproj1  -configProject  "OSB Configuration"  -configSubProjects  OSBProject  -configJar  sbconfig.jar

keep in mind, "-data  D:\proj\osbproj1" points to source directory of your OSB Configuration and OSB project. In this case, i have an "OSB Configuration" project, and an "OSBProject".