Showing posts with label ANT. Show all posts
Showing posts with label ANT. Show all posts

Tuesday, June 4, 2013

Caused by: java.lang.NoClassDefFoundError: org/apache/xmlbeans/SchemaTypeLoader while trying to export OSB Project from eclipse workspace

Recently I encountered a problem while trying to export OSB project from eclipse workspace.

Even though I set the class path properly, still it was throwing the following error

Caused by: java.lang.NoClassDefFoundError: org/apache/xmlbeans/SchemaTypeLoader.

After a long search in net, I found the following recommendation and it works!

Add the additional property for the java activity
 <sysproperty key="middleware.home" value="${fmw.home}"/>


The complete structure as follows

First create the classpath variable

 <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="${weblogic.home}/server/lib">
        <include name="weblogic.jar"/>
      </fileset>
      <fileset dir="${osb.home}/lib">
        <include name="alsb.jar"/>
      </fileset>
   </path>



<target name="exportFromWorkspace">
          <java dir="${eclipse.home}" classpathref="library.osb"
           jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar"
           fork="true" failonerror="true" maxmemory="768m">
         <jvmarg line="-XX:MaxPermSize=256m"/>
        <arg line="-data ${workspace.dir}"/>
        <arg line="-application com.bea.alsb.core.ConfigExport"/>
        <arg line="-configProject ${config.project}"/>
        <arg line="-configJar ${config.jar}"/>
        <arg line="-configSubProjects ${config.subprojects}"/>
        <arg line="-includeDependencies ${config.includeDependencies}"/>
        <sysproperty key="weblogic.home" value="${weblogic.home}"/>
        <sysproperty key="osb.home" value="${osb.home}"/>
        <sysproperty key="osgi.bundlefile.limit" value="500"/>
        <sysproperty key="harvester.home" value="${osb.home}/harvester"/>
        <sysproperty key="osgi.nl" value="en_US"/>
        <sysproperty key="sun.lang.ClassLoader.allowArraySyntax" value="true"/>
      <sysproperty key="middleware.home" value="${fmw.home}"/>
     </java>
   </target>

Even after that if export fails, try to add the section to delete .metadata folder as shown below

<target name="exportFromWorkspace">
      <delete failonerror="false" includeemptydirs="true"
              dir="${metadata.dir}"/>
      <java dir="${eclipse.home}" classpathref="library.osb"
            jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar"
            fork="true" failonerror="true" maxmemory="768m">
         <jvmarg line="-XX:MaxPermSize=256m"/>
         <arg line="-data ${workspace.dir}"/>
         <arg line="-application com.bea.alsb.core.ConfigExport"/>
         <arg line="-configProject ${config.project}"/>
         <arg line="-configJar ${config.jar}"/>
         <arg line="-configSubProjects ${config.subprojects}"/>
         <arg line="-includeDependencies ${config.includeDependencies}"/>
         <sysproperty key="weblogic.home" value="${weblogic.home}"/>
         <sysproperty key="osb.home" value="${osb.home}"/>
         <sysproperty key="osgi.bundlefile.limit" value="500"/>
         <sysproperty key="harvester.home" value="${osb.home}/harvester"/>
         <sysproperty key="osgi.nl" value="en_US"/>
         <sysproperty key="sun.lang.ClassLoader.allowArraySyntax" value="true"/>
        <sysproperty key="middleware.home" value="${fmw.home}"/>
      </java>
   </target>



Monday, December 3, 2012

For task in ANT

We might require to use for task in the ANT scripts.

By default for task in not available with basic ANT installation

Using the ant-contrib jar file we can define "for" task in build script.

Copy the ant-contrib-version.jar to the ANT_HOME lib folder and in the build script add the following section

  <project name="SOA_OSB_Deployment" basedir="." default="init">
     <taskdef resource="net/sf/antcontrib/antlib.xml"/>
     <target name="init">
            <for list="1,2,3,4,5" param="letter">
<sequential>
<echo>Letter @{letter}</echo>
</sequential>
</for>
      </target>
  </project>

Note : we should use net/sf/antcontrib/antlib.xml  not  net/sf/antcontrib/antcontrib.properties

Also the ant-contrib-version.jar can be kept any location, but we need to explicitly tell ant script where to locate the file


<taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
    <pathelement location="/usr/share/ant/lib/ant-contrib-version.jar"/>
  </classpath>
</taskdef>