Thursday, July 11, 2013

JAVA: The filename, directory name, or volume label syntax is incorrect

While doing file copy operation using java, if we come across an error saying

"The filename, directory name, or volume label syntax is incorrect"

then check the source filename which we are trying to copy and ensure there is no white space before or after the filename.

Better to use fileName.trim() before trying to copy

Wednesday, July 10, 2013

B2B : java.lang.UnsatisfiedLinkError: com.edifecs.xengine.xeobjects.XEHelper.createSourceFromBLOBNative

If B2B transaction is failed , check the server logs, and if the below error is found, then it is an issue with loading the native library for XEEngine

java.lang.UnsatisfiedLinkError: com.edifecs.xengine.xeobjects.XEHelper.createSourceFromBLOBNative(Ljava/lang/String;[BLjava/lang/String;)Lcom/edifecs/xengine/xeobjects/XESource;    

To solve this issue, do the following steps

1) set the library path in setSOADomainEnv.cmd as follows
set JAVA_OPTIONS=%JAVA_OPTIONS% -Djava.library.path=<middlewarehome>\Oracle_SOA1\soa\thirdparty\edifecs\XEngine\bin

2) copy the wlntio.dll from <middlewarehome>\wlserver_10.3\server\native\win\x64  to <middlewarehome>\Oracle_SOA1\soa\thirdparty\edifecs\XEngine\bin

3) copy the wlntio.dll from <middlewarehome>\wlserver_10.3\server\native\win\x64  to <JAVAHOME>\bin

also ensure the following properties are set setSOADomainEnv.cmd
set XENGINE_DIR=" <middlewarehome>\Oracle_SOA1\soa\thirdparty\edifecs\XEngine"
set PATH=%PATH%; <middlewarehome>\Oracle_SOA1\soa\thirdparty\edifecs\XEngine\bin

Restart both Admin and ManagedServer . Ensure you have run the script setSOADomainEnv.cmd before restarting the server

Tuesday, July 2, 2013

How to get the list of partitions of em using java - SOA 11g



The following java code will  get all the partitions available in em


public static ArrayList getPartitions(String host,String port,String username,String password) throws Exception
{
 System.out.println("Trying list all partitions in "+host);
  ArrayList partitions = new ArrayList();
    boolean found = false;

String contextFactory = "weblogic.jndi.WLInitialContextFactory";

String mbeanRuntime = "weblogic.management.mbeanservers.runtime";
String jmxProtoProviderPackages = "weblogic.management.remote";

String mBeanNamePartition = "oracle.soa.config:Application=soa-infra,j2eeType=FolderLifecycleConfig,name=soa-infra";
MBeanServerConnection mbsc = TestComposite.getMbeanServerConnection(host, port, username, password,mbeanRuntime,jmxProtoProviderPackages);


ObjectName mbeanpartition = new ObjectName(mBeanNamePartition);

Object FolderArray = mbsc.getAttribute(mbeanpartition, "Folders");
System.out.println("FolderArray ="+FolderArray);
Folder[] folderData = (Folder[]) FolderArray;
for (int i = 0; i < folderData.length; i++) {
System.out.println("Folder Data"+folderData[i].getName());
partitions.add(folderData[i].getName());
}


System.out.println("partitions size"+partitions.size());
return partitions;

}

Server is Running in Development Mode and Native Library(terminalio) to read the password se curely from commandline is not found

In case we encounter this type of error, in the setSOADomainEnv.cmd add an additional attribute (-Dweblogic.management.allowPasswordEcho=true) to the the JAVA_OPTIONS as shown below

set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.management.allowPasswordEcho=true


Now , open a new command prompt and run the setSOADomainEnv.cmd.

Then start the server from the command prompt.



In case of unix system,

edit the   setSOADomainEnv.sh  as shown below

export JAVA_OPTIONS="$JAVA_OPTIONS -Dweblogic.management.allowPasswordEcho=true"

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>



Thursday, May 9, 2013

Sorting xml based on a tag value

If we want to sort an xml based on a field's value, we can use the following approch

Say for e.g  This is the source xml



<?xml version="1.0" encoding="UTF-8"?>
<OrganizationList>
   <Organization>
      <Name>Bharath</Name>
      <System>automotive</System>
      <main>Y</main>
   </Organization>
   <Organization>
      <Name>ATP</Name>
      <System>supply</System>
      <main>N</main>
   </Organization>
   <Organization>
      <Name>BSNL</Name>
      <System>service</System>
      <main>Y</main>
   </Organization>
</OrganizationList>


If we want to sort the above xml based on the value of main tag we can use the following approach




<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="xsl">
   <xsl:template match="node()">
      <xsl:copy>
         <xsl:apply-templates />
      </xsl:copy>
   </xsl:template>
   <xsl:template match="OrganizationList">
      <xsl:copy>
         <xsl:apply-templates>
            <xsl:sort order="descending" select="main" />
         </xsl:apply-templates>
      </xsl:copy>
   </xsl:template>
</xsl:stylesheet>


The result will be as shown below



<?xml version="1.0" encoding="UTF-8"?>
<OrganizationList>
   <Organization>
      <Name>Bharath</Name>
      <System>automotive</System>
      <main>Y</main>
   </Organization>
   <Organization>
      <Name>BSNL</Name>
      <System>service</System>
      <main>Y</main>
   </Organization>
   <Organization>
      <Name>ATP</Name>
      <System>supply</System>
      <main>N</main>
   </Organization>
</OrganizationList>





xquery : increment index in for each loop

Unlike java we cannot increment a variable's value in xquery while using for loop.

Say for e.g if we declare the following count variable in xquery and try to use it in the mapping, it will never work as we expect

 let $count := 0
 for $record at $position in $collection/books
                    let $count :=  $count + 1

                    return
                     <ns1:books>
                        <ns1:name>{ $record/name }</ns1:name>
                        <ns1:sequence>{ $count) }</ns1:sequence>
</ns1:books>


Instead we can use the following approach.

While declaring the for loop also declare a position variable.

Use this position variable in the place of count as follows


 for $record at $position in $collection/books
                   return
                     <ns1:books>
                        <ns1:name>{ $record/name }</ns1:name>
                        <ns1:sequence>{ $position) }</ns1:sequence>
   </ns1:books>