Sunday, 31 May 2015

OAF: Import/Export Page/Personalization/Substitution using XMLImporter/JPXImporter in Oracle Application Framework

In this post, I will give the syntax for importing/exporting page/personalization/substitution in OA Framework from unix/windows machines.

Import Page/Personalization.
We will use the class XMLIMporter for importing the page or personalization into the database.

From Unix:
 java oracle.jrad.tools.xml.importer.XMLImporter <dir_path>/<file_name>.xml 
 -username <user_name> -password <password> 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<host_name>)(PORT= <port_number>)) (CONNECT_DATA=(SID=<database_sid>)))" 
 -rootdir <dir_path> -rootPackage <package>  
Example:
 java oracle.jrad.tools.xml.importer.XMLImporter $PWD/TestPG.xml 
 -username apps -password apps 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.160.129) (PORT=1522))(CONNECT_DATA=(SID=VIS121)))" 
 -rootdir $PWD -rootPackage /ajtest/oracle/apps/fnd/test/webui/  
 java oracle.jrad.tools.xml.importer.XMLImporter $PWD/TestPG.xml 
 -username apps -password apps 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.160.129) (PORT=1522))(CONNECT_DATA=(SID=VIS121)))" 
 -rootdir $PWD -rootPackage /ajtest/oracle/apps/fnd/test/webui/customizations/site/0/  
From Windows:
The import.bat file will be available under the Jdev installation under jdevbin/oaext/bin
 import <dir_path>/<file_name>.xml 
 -username <user_name> -password <password> 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<host_name>)(PORT=<port_number>))(CONNECT_DATA=(SID=<database_sid>)))" 
 -rootDir <dir_path> -rootPackage <package>  
Example:
 C:\oracle\JdevR12.1.3\jdevbin\oaext\bin\import C:\oracle/JdevR12.1.3/jdevbin/jdev/myprojects/ajtest/oracle/apps/fnd/test/webui/TestPG.xml 
 -username apps -password apps 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.160.129)(PORT=1522))(CONNECT_DATA=(SID=VIS121)))" -rootDir C:\oracle/JdevR12.1.3/jdevbin/jdev/myprojects/ 
 -rootPackage /ajtest/oracle/apps/fnd/test/webui/  
Import EO/VO/AM Substitution.
We will use the class JPXIMporter for importing the substitution into the database.
 java oracle.jrad.tools.xml.importer.JPXImporter <dir_path>/<file_name>.jpx 
 -username <user_name> -password <password> 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<host_name>)(PORT= <port_number>)) (CONNECT_DATA=(SID=<database_sid>)))"  
Example:
 java oracle.jrad.tools.xml.importer.JPXImporter $PWD/AJProject.jpx 
 -username apps -password apps 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.160.129) (PORT=1522))(CONNECT_DATA=(SID=VIS121)))"  
Export Page/Personalization.
We will use the class XMLExporter for exporting the page or personalization from the database. When you execute these commands don't give the extension for the file name. 

From Unix:
 java oracle.jrad.tools.xml.exporter.XMLExporter <dir_path>/<file_name> -rootdir <dir_path> 
 -username <user_name> -password <password> 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<host_name>)(PORT=<port_number>))(CONNECT_DATA=(SID=<database_sid>)))"  
Example:
 java oracle.jrad.tools.xml.exporter.XMLExporter /ajtest/oracle/apps/fnd/test/webui/TestPG 
 -rootdir $PWD 
 -username apps -password apps 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.160.129)(PORT=1522))(CONNECT_DATA=(SID=VIS121)))"  
From Windows:
The export.bat file will be available under the Jdev installation under jdevbin/oaext/bin
 export <dir_path>/<file_name> 
 -rootdir <dir_path> 
 -username <user_name> -password <password> 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<host_name>)(PORT=<port_number>))(CONNECT_DATA=(SID=<database_sid>)))"  
Example:
 C:\oracle\JdevR12.1.3\jdevbin\oaext\bin\export /ajtest/oracle/apps/fnd/test/webui/TestPG 
 -rootdir C:\test\ 
 -username apps -password apps 
 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.160.129)(PORT=1522))(CONNECT_DATA=(SID=VIS121)))"  

You can also export the files from database using jdr_utils package, which is explained in my other blog JDR_UTILS.

Related Links: OAF: Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file

Feel free to point out if anything is missing/wrong in this blog.

Saturday, 30 May 2015

OAF: How to create a HTML Tab Menu in Oracle Application Framework

I have seen couple of questions in OTN Forum on how to create a HTML Tab Menu in OA Framework. So here I will explain the structure to create a Menu Structure like the one given below:

It would be better to write down the Menus and the Functions based on your requirement first. Then start to create the Function --> HTML Tab Menu --> Home Page Menu --> Standard Menu (Root Menu) --> Responsibility.

The Menu selection is highlighted using the OAHP (Home Page) and OASF (Selected Function) parameters in the Web HTML Call of the Function definition. 

The Menus and Functions defined in this example is given below.
Menu Definition
Header Syntax: User Menu Name (Menu) [Menu Type]
Line   Syntax: Seq --> Prompt --> SubMenu --> Function
 AJ Menu Root(AJ_MENU_ROOT)[Standard]  
      10 --> Home --> ---          --> AJ Function Home  
      20 --> ---  --> AJ Menu Home --> ---  
 AJ Menu Home(AJ_MENU_HOME)[Home Page]  
      10 --> ---        --> ICX_STANDARD_GLOBAL_MENU --> ---  
      20 --> ABC Header --> AJ ABC Header Menu       --> ---  
      30 --> XYZ Header --> AJ XYZ Header Menu       --> ---  
 AJ ABC Header Menu (AJ_ABC_HEADER_MENU)[HTML Tab]  
      10 --> A Line   --> ---  --> AJ A Line Function  
      20 --> B Line   --> ---  --> AJ B Line Function  
      30 --> C Line   --> ---  --> AJ C Line Function  
 AJ XYZ Header Menu (AJ_XYZ_HEADER_MENU)[HTML Tab]  
      10 --> X Line   --> ---  --> AJ X Line Function  
      20 --> Y Line   --> ---  --> AJ Y Line Function  
      30 --> Z Line   --> ---  --> AJ Z Line Function  
Function Definition
Header Syntax: User Function Name (Function)
Line   Syntax: HTML Call
 AJ A Line Function (AJ_A_LINE_FUNC)  
      OA.jsp?page=/ajtest/oracle/apps/fnd/test/webui/TestPG&OAHP=AJ_MENU_HOME&OASF=AJ_A_LINE_FUNC  
 AJ B Line Function (AJ_B_LINE_FUNC)  
      OA.jsp?page=/ajtest/oracle/apps/fnd/test/webui/TestPG&OAHP=AJ_MENU_HOME&OASF=AJ_B_LINE_FUNC  
 AJ C Line Function (AJ_C_LINE_FUNC)  
      OA.jsp?page=/ajtest/oracle/apps/fnd/test/webui/TestPG&OAHP=AJ_MENU_HOME&OASF=AJ_C_LINE_FUNC  
 AJ X Line Function (AJ_X_LINE_FUNC)  
      OA.jsp?page=/ajtest/oracle/apps/fnd/test/webui/TestPG&OAHP=AJ_MENU_HOME&OASF=AJ_X_LINE_FUNC  
 AJ Y Line Function (AJ_Y_LINE_FUNC)  
      OA.jsp?page=/ajtest/oracle/apps/fnd/test/webui/TestPG&OAHP=AJ_MENU_HOME&OASF=AJ_Y_LINE_FUNC  
 AJ Z Line Function (AJ_Z_LINE_FUNC)  
      OA.jsp?page=/ajtest/oracle/apps/fnd/test/webui/TestPG&OAHP=AJ_MENU_HOME&OASF=AJ_Z_LINE_FUNC  
 AJ Function Home(AJ_FUNCTION_HOME)  
      OA.jsp?OAFunc=AJ_A_LINE_FUNC&OAHP=AJ_MENU_HOME&OASF=AJ_FUNCTION_HOME  
Screenshot of the Responsibility/Menu/Functions below:

  • Responsibility
  • Root Menu
  • Home Page Menu
  • ABC Header Menu [HTML Tab]

  • XYZ Header Menu [HTML Tab]
  • Functions
Make sure you clear the cache using Functional Administrator, before you try to access the Menu. Once you run the page the outputs will be like below:



The contents of all the pages looks the same because, I have created only one PG.xml :)

Feel free to point out if anything is missing/wrong in this blog.

Sunday, 24 May 2015

OAF: Creating custom CSS in Oracle Application Framework.

Recently I saw a question in OTN Forum on how to create custom CSS in OA Framework. Its long time I have done some custom CSS for OA Framework. So thought of putting a blog on how to add custom CSS for OAF Pages.

Refer the below link for Standard CSS available : Text (CSS) Standards
To get the HTML Color Codes : HTML Color Codes and Names

To add custom style sheet to your application, you need to modify the custom.xss file. The file is available under $OA_HTML/cabo/styles.

#1. Using custom.css
  • Take a backup of the custom.xss
  • Add the code between the below lines in the custom.css
 <!-- Please start your customizations here -->  
  // Add the custom code here  
 <!-- Please end your customizations here -->  
  • Sample code
 <!-- Please start your customizations here -->  
      <style name="CustomStyle1">  
           <property name="color">#0000FF</property>  
           <property name="background-color">#FFFF00</property>  
      </style>  
      <style selector=".XXCustomStyle1">  
        <includeStyle name="CustomStyle1"/>  
      </style>  
     <style name="CustomStyle2">  
           <property name="color">#FF0000</property>  
           <property name="background-color">#00FF00</property>  
           <property name="font-weight">bold</property>  
      </style>  
      <style selector=".XXCustomStyle2">  
        <includeStyle name="CustomStyle2"/>  
      </style>  
 <!-- Please end your customizations here -->  

  • Now you can refer the new style in the page using "XXCustomStyle1" for the CSS Class property of the beans in the page.

#2. Writing code in Controller
 import oracle.cabo.style.CSSStyle;  
 CSSStyle customStyle = new CSSStyle();  
 customStyle.setProperty("color", "#FFA500");  
 customStyle.setProperty("font-size", "13pt");
   
 OAMessageDateFieldBean dateBean = (OAMessageDateFieldBean)webBean.findChildRecursive("DateBean");  
 dateBean.setInlineStyle(customStyle);  
  • Find the screen shot below to see the output of the above code. First column is based on the controller code and the 2nd and 3rd columns are based on the custom.xss.
  • Now, you can also make use of the OADataBoundValueViewObject class to dynamically change the CSS.  I have modified the View Object query to add an extra column 'CustomCssStyleAttr'. I am getting the Custom CSS Style Class as an attribute. In the below query, we will get 3 different values, XXCustomStyle1, XXCustomStyle2, NULL. The query is as below.
 select creation_date start_date  
     ,user_id Hours  
     ,decode(mod(rownum,3),0,NULL,1,'XXCustomStyle1',2,'XXCustomStyle2') CUSTOM_CSS_STYLE_ATTR  
 from fnd_user  
  • Also, modifed the controller code as below.
 CSSStyle customStyle = new CSSStyle();  
 customStyle.setProperty("color", "#FFFFFF");  
 customStyle.setProperty("background-color", "#FF00FF");  
 customStyle.setProperty("font-size", "11pt");
   
 OAMessageDateFieldBean dateBean = (OAMessageDateFieldBean)webBean.findChildRecursive("DateBean");  
 dateBean.setInlineStyle(customStyle);
  
 OAColumnBean customStyleCol = (OAColumnBean)webBean.findChildRecursive("CustomStyleCol");  
 OADataBoundValueViewObject customStyleCSS = new OADataBoundValueViewObject(customStyleCol, "CustomCssStyleAttr");  
 customStyleCol.setAttributeValue(oracle.cabo.ui.UIConstants.STYLE_CLASS_ATTR,customStyleCSS);  
  • Now see the output.
If your changes are not reflecting in the page, remove the files from  $OA_HTML/cabo/styles/cache directory and bounce the server.

References :
https://community.oracle.com/thread/600398?start=0&tstart=15
https://community.oracle.com/thread/1056912?tstart=0
http://abhayappssolution.blogspot.com.au/2013/03/custom-font-for-message-text-items-on.html

Feel free to point out if anything is missing/wrong in this blog.

Friday, 22 May 2015

OAF: How to handle SelectAll / SelectNone on a table region in Oracle Application Framework

Some time we need to handle to SelectAll / Select None clicks or even the single Selection to do some extra logic. It is not easy to capture those events and you cannot add a firePartialAction to those components declaratively (I haven't researched is there an option to add firePartialAction programmatically). In this post I will explain an easy way to achieve this functionality. 

In this approach we are not using the multipleSelection feature of the table/advancedTable region. Instead we create a custom column and custom Select All/Select None links.

In the example we are using a viewObject TestVO with a simple query and a transient attribute "SelectAttr" for the selection.
  • Add a messageCheckBox as the first column in the table and associate the attribute 'SelectAttr'. Set the Checked Value to 'Y', Unchecked Value to 'N', Action Type to 'firePartialAction' and Event to 'Select'.

  • Add the tableAction region to the table. [Right click on the table, New --> tableActions].
  • Create a RowLayoutRegion in the tableAction region and add the below components:
          Item1(SelectAllLink):
                                   Item Style: link
                                   Text: Select All
                                   Action Type: firePartialAction
                                   Event: SelectAll
          Item2(Spacer1):
                                   Item Style: spacer
                                   Width: 3
          Item3(Separator):
                                   Item Style: rawText
                                   Text: |
          Item4(Spacer2):
                                   Item Style: space
                                   Width: 3
          Item5(SelectNoneLink):
                                   Item Style: link
                                   Text: Select All
                                   Action Type: firePartialAction
                                   Event: SelectAll
  • Now we can handle the CheckBox and the Select All and Select None events in the Controller.
  • To handle the SelectAll event use the below code.The first method updates all rows in the VO. The second method updates only the rows in Range (which means only the once we see on the screen, based on the 'Records Displayed' property of the table).
 if("SelectAll".equals(eventParam)) {  
      OAViewObjectImpl testVO = (OAViewObjectImpl)appModule.findViewObject("TestVO1");  
      RowSetIterator rowSetIterator = testVO.createRowSetIterator("TestIter");  
      rowSetIterator.reset();  
      while (rowSetIterator.hasNext()){  
           Row row = rowSetIterator.next();  
           row.setAttribute("SelectAttr","Y");  
      }  
      rowSetIterator.closeRowSetIterator();  
 }  
 if("SelectAll".equals(eventParam)) {  
      OAViewObjectImpl testVO = (OAViewObjectImpl)appModule.findViewObject("TestVO1");  
      Row rows[] = testVO.getAllRowsInRange();  
      for(Row row : rows){  
           row.setAttribute("SelectAttr","Y");  
      }  
 }  
    • To handle the SelectNone event use the below code.The first method updates all rows in the VO. The second method updates only the rows in Range (which means only the once we see on the screen, based on the 'Records Displayed' property of the table).

     if("SelectNone".equals(eventParam)) {  
          OAViewObjectImpl testVO = (OAViewObjectImpl)appModule.findViewObject("TestVO1");  
          RowSetIterator rowSetIterator = testVO.createRowSetIterator("TestIter");  
          rowSetIterator.reset();  
          while (rowSetIterator.hasNext()){  
               Row row = rowSetIterator.next();  
               row.setAttribute("SelectAttr","N");  
          }  
          rowSetIterator.closeRowSetIterator();  
     }  
    
     if("SelectNone".equals(eventParam)) {  
          OAViewObjectImpl testVO = (OAViewObjectImpl)appModule.findViewObject("TestVO1");  
          Row rows[] = testVO.getAllRowsInRange();  
          for(Row row : rows){  
               row.setAttribute("SelectAttr","N");  
          }  
     }  
    
    • To handle the check box Select, use the below code.
     if ("Select".equals(eventParam)){  
           String eventRowSourceParam = pageContext.getParameter(EVENT_SOURCE_ROW_REFERENCE);  
           Row row = appModule.findRowByRef(eventRowSourceParam);  
     }  
    

    • In the below screen shot you can see both the Standard and the Custom Links. The one marked in Yellow color is the custom ones.
    • When you remove the Stanadard multiSelection on the table, the page will look like below (infact you save some space as well :)).
    The pages (PG.xml and CO.java) used for the above demo can be downloaded from here.

    Feel free to point out if anything is missing/wrong in this blog.

    ADF/OAF: How to create Dynamic View Object in Controller in Oracle Application Framework

    In this post I will give sample code to to create a View Object dynamically/programatically/runtime in Oracle Applications Framework in a Controller. 
    Applicable to ADF Web Applications also.

     import oracle.jbo.Row;  
     import oracle.jbo.ViewObject;  
     import oracle.apps.fnd.framework.OAApplicationModule;  
    
     public void processRequest(OAPageContext pageContext, OAWebBean webBean) {  
          super.processRequest(pageContext, webBean);  
          OAApplicationModule appModule = pageContext.getApplicationModule(webBean);  
          if(appModule != null)   
          {  
               ViewObject dynamicVO = appModule.findViewObject("DynamicVO");  
               if(dynamicVO == null)   
               {  
                    String querySql = "select user_id, user_name from fnd_user where rownum < 5";  
                    dynamicVO = appModule.createViewObjectFromQueryStmt("DynamicVO",querySql);  
               }  
               if(dynamicVO != null)   
               {  
                    dynamicVO.setWhereClause(null);  
                    dynamicVO.setWhereClauseParams(null);  
                    dynamicVO.executeQuery();  
                    for(Row dynamicVORow = dynamicVO.first(); dynamicVORow != null; dynamicVORow = dynamicVO.next()) {  
                         System.out.println("----------");  
                         System.out.println("User ID:" + dynamicVORow.getAttribute(0));  
                         System.out.println("User ID:" + dynamicVORow.getAttribute("USER_ID"));  
                         System.out.println("User Name:" + dynamicVORow.getAttribute(1));  
                         System.out.println("User Name:" + dynamicVORow.getAttribute("USER_NAME"));  
                    }  
               }  
          }  
     }  
    
    You can modify the querySql as per your need. You add additional whereclause as you want. You can also create without whereclause and add dynamic whereclause if needed.

    Attributes can be accessed either with the position or using the uppercase of the column name specified in the query.

    Feel free to point out if anything is missing/wrong in this blog.

    Thursday, 21 May 2015

    ADF/OAF/Java: Playing with Dates in Oracle Application Framework

    In this post I will give examples of converting date from one datatype to another from a Oracle Application Framework perspective. These examples will be useful/handy when you have date value in a specific format and you want to convert/manipulate. I will add more examples when I get more free time  :-)
    Applicable to ADF Web Application also.

    If you have a requirement which is not mentioned here, feel free to ask.

    I will be using the below classes in the examples:

    oracle.jbo.domain.Date;
    oracle.jbo.domain.Timestamp;
    java.sql.Date;
    java.sql.Timestamp;
    java.util.Date;
    java.util.Calendar;
    java.text.DateFormat;
    java.text.SimpleDateFormat;
    java.lang.String;

    #1. Get the current Date time.
    • Using java.util.Date.
     import java.util.Date;  
    
     Date utilDate = new Date();   
     System.out.println("utilDate :" + utilDate);   
    • Using oracle.jbo.domain.Date.
     import java.sql.Timestamp;                   
     import oracle.jbo.domain.Date;  
    
     Timestamp sqlTimestamp = new Timestamp(System.currentTimeMillis());    
     Date jboDomainDate = new Date(sqlTimestamp);  
     System.out.println("jboDomainDate :" + jboDomainDate);  
    
    • Using java.util.Calendar.
     import java.util.Calendar;  
    
     Calendar utilCalendar = Calendar.getInstance();   
     System.out.println("utilCalendar :" + utilCalendar);  
    
    #2. Get the current Date time in oracle.jbo.domain.Date and add 10 hours to that and get the time back in oracle.jbo.domain.Date along with the time component.
     import oracle.jbo.domain.Date;  
     import java.sql.Timestamp;  
     import java.util.Calendar;  
    
     Timestamp datetime = new Timestamp(System.currentTimeMillis());   
     Date jboDomainStartDate = new Date(datetime);   
     System.out.println("jboDomainDate :" + jboDomainStartDate);
      
     Calendar utilCalendar = Calendar.getInstance();   
     utilCalendar.setTime(jboDomainStartDate.getValue());   
     System.out.println("utilCalendar Start:" + utilCalendar.getTime());
       
     int hoursToAdd = 10;   
     utilCalendar.add(Calendar.HOUR, hoursToAdd);   
     System.out.println("utilCalendar End:" + utilCalendar.getTime());
       
     Timestamp sqlTimeStampEnd = new Timestamp(utilCalendar.getTime().getTime());   
     Date jboDomainEndDate = new Date(sqlTimeStampEnd);   
     System.out.println("jboDomainEndDate :" + jboDomainEndDate);
      
    
    #3. To print the Current time in DD-MON-YYYY HH24:MI:SS format.
     import java.text.SimpleDateFormat;  
     import java.text.DateFormat;  
     import java.util.Calendar;  
    
     DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");  
     Calendar cal = Calendar.getInstance();
     String dateStr = dateFormat.format(cal.getTime());    
     System.out.println("Current Time : " + dateStr);  
    
    Refer: Class SimpleDateFormat
    #4. To get the oracle.jbo.domain.Date in DD-MON-YYYY HH24:MI:SS format.
     import java.text.SimpleDateFormat;  
     import java.text.DateFormat;  
     import java.util.Calendar;  
    
     // This is a sample code to initialize the domain Date
     Timestamp datetime = new Timestamp(System.currentTimeMillis());   
     Date jboDomainDate = new Date(datetime); 
             
     DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");  
     String dateStr = dateFormat.format(jboDomainDate.getValue());   
     System.out.println("Current Time : " + dateStr);  
    
    #5. To get the difference between two oracle.jbo.domain.Date in days.
     import oracle.jbo.domain.Date;  
    
     Date jboDomainStartDate = null;  
     Date jboDomainEndDate  = null;
     
     // Code to get the date Values has to be written here 
      
     int diffDays = (int)((jboDomainEndDate.getValue().getTime() - jboDomainStartDate.getValue().getTime()) / (1000 * 60 * 60 * 24));  
     System.out.println("Diff in days:"+ diffDays);  
    
    #6. To convert string oracle.jbo.domain.Date.
     import java.text.SimpleDateFormat;   
     import java.text.DateFormat;  
     import oracle.jbo.domain.Date;  
    
     try  
     {  
          DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");  
          java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse("10-JAN-2010").getTime());   
          Date jboDomainDate = new Date(sqlDate);  
     }catch(Exception e) {  
          System.out.println(e.getMessage());  
          // throw appropirate Error Message  
     }  
    
    #7. Calculate the age based on the Date of Birth from a oracle.jbo.domain.Date.
      import oracle.jbo.domain.Date;   
      import java.util.Calendar;  
    
      Date doB = null;  
      // get the DOB and populate the doB variable  
         
      Calendar dob = Calendar.getInstance();  
      dob.setTimeInMillis(doB.getValue().getTime());  
         
      Calendar sysDate = Calendar.getInstance();  
         
      int age = sysDate.get(Calendar.YEAR) - dob.get(Calendar.YEAR);  
         
      if ((dob.get(Calendar.MONTH) > sysDate.get(Calendar.MONTH))  
           ||   
          (dob.get(Calendar.MONTH) == sysDate.get(Calendar.MONTH) &&   
               dob.get(Calendar.DAY_OF_MONTH) > sysDate.get(Calendar.DAY_OF_MONTH))) {  
        age--;  
      }  
      System.out.println("Age:" + age);  
    


    Feel free to point out if anything is missing/wrong in this blog.

    Wednesday, 20 May 2015

    OAF: Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file

    Recently when I was trying to import a page XML into a R12.1.3 instance in a VM using XMLImporter, I got the below error:
     Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file  
         at java.lang.ClassLoader.defineClass2(Native Method)  
         at java.lang.ClassLoader.defineClass(ClassLoader.java:719)  
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:160)  
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:254)  
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)  
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)  
         at java.security.AccessController.doPrivileged(Native Method)  
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)  
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)  
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)  
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)  
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)  
         at java.lang.Class.forName0(Native Method)  
         at java.lang.Class.forName(Class.java:164)  
         at oracle.adf.mds.tools.util.ConnectUtils.getDBConnection(ConnectUtils.java:165)  
         at oracle.jrad.tools.xml.importer.XMLImporter.importDocuments(XMLImporter.java:228)  
         at oracle.jrad.tools.xml.importer.XMLImporter.main(XMLImporter.java:84)  
    
    Reason:
    Wrong java version was referenced, because the I didn't run the environment file.

    I was getting the below details when I run "java -version"
     java version "1.5.0_08"  
     Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)  
     Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)  
    
    Solution:
    Source the environment using the .env file, before trying to run the import command. Once the environment file is run, it will set the environment variables. You need to run this before running any utilities.

    In some cases, it will be configured to run automatically.

    The command I used :
     . /oracle/r12/VIS121/apps/apps_st/appl/APPSVIS121_ebs121-vm.env  
    
    I got the below details when I run "java -version" after sourcing the environment.
     java version "1.6.0"  
     OpenJDK Runtime Environment (build 1.6.0-b09)  
     OpenJDK Client VM (build 1.6.0-b09, mixed mode)  
    

    Hope this helps someone.

    Feel free to point out if anything is missing/wrong in this blog.