Tuesday, September 1, 2020

MAC Error: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

Did you just upgrade your MAC OS? Are you now receiving this error?

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Solution:
Run the following command on the terminal
xcode-select --install


Please share your feedback below. Hope you find this helpful!

CaptiveCode


Thursday, September 7, 2017

How To: Launch a popup programmatically (ADF)

Create a binding for the popUp in the backing bean and use the following snippet to launch it programmatically






Hope you find this helpful! Please share your feedback below.

CaptiveCode


Monday, September 4, 2017

How To: Access one managed bean from another (ADF, JSF)

It is a common requirement to access methods between managed beans defined in varied scopes within ADF. In this post, I am invoking backing bean (method to enable/disable a button) from a request bean. The similar approach can be used for other scopes viz. pageFlow, session, application.


Download Sample Code on GitHub


Define your managed beans in your task flow:
    <managed-bean id="__1">
      <managed-bean-name id="__243">RequestBean</managed-bean-name>
      <managed-bean-class id="__244">ui.bean.RequestBean</managed-bean-class>
      <managed-bean-scope id="__245">request</managed-bean-scope>
    </managed-bean>
    <managed-bean id="__2">
      <managed-bean-name id="__248">BackingBean</managed-bean-name>
      <managed-bean-class id="__246">ui.bean.BackingBean</managed-bean-class>
      <managed-bean-scope id="__247">backingBean</managed-bean-scope>
    </managed-bean>
BackingBean Definition:
package ui.bean;

import oracle.adf.view.rich.component.rich.nav.RichCommandToolbarButton;

public class BackingBean {
    private RichButton submitBtn;

    public void setSubmitBtn(RichButton submitBtn) {
        this.submitBtn = submitBtn;
    }

    public RichButton getSubmitBtn() {
        return submitBtn;
    }
}
RequestBean Definition:
package ui.bean;

import javax.el.ELContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

public class RequestBean {

    public BackingBean getBackingBean() {
        FacesContext fctx = FacesContext.getCurrentInstance();
        ELContext context = fctx.getELContext();
        BackingBean backingBean =
            (BackingBean) fctx.getApplication().getExpressionFactory()
                .createValueExpression(context,"#{backingBeanScope.BackingBean}",BackingBean.class)
                .getValue(context);
        return backingBean;
    }

    public void enableSubmit(ActionEvent actionEvent) {
        /* Invoke BackingBean method to enable/disable Submit Button */
        getBackingBean().getSubmitBtn().setDisabled(false);
    }
}



Hope you find this helpful! Please share your feedback below.

CaptiveCode


How To: Execute View Criteria programmatically

Consider the following view criteria is defined on a view object:




To execute this view criteria programmatically, write the following method in the AMImpl class:
    public void executeInvoiceVOCriteria(String invoiceNum, String poNum){
        ViewObjectImpl vo = getInvoiceVO1();        
        ViewCriteria vc = vo.getViewCriteria("InvoiceVOCriteria");
        vo.applyViewCriteria(vc);
        vo.setNamedWhereClauseParam("p_inv_num", invoiceNum);
        vo.setNamedWhereClauseParam("p_po_num", poNum);
        vo.executeQuery();
    }




Hope you find this helpful! Please share your feedback below.

CaptiveCode


Sunday, September 3, 2017

How To: Pass parameters to action listener in ADF

I have commonly come across the requirement to pass parameters to the managed bean method on a button click. The challenge we normally face here is that, the methods attached to the "action" or "actionListener" have fixed signatures that cannot be changed.

Thus, we have to leverage the "<f:attribute>" tag alongwith a "actionListener"


Hope you find this helpful! Please share your feedback below.
CaptiveCode


How To: Throw an exception in ADF

To show an exception on ADF UI, implement the following in your managed bean:




Hope you find this helpful! Please share your feedback below.

CaptiveCode


Saturday, March 25, 2017

How To: Deploying applications on WebLogic using command line

This article is a quick reference on how to deploy applications to WebLogic server using command line interface.

Set classpath as follows:
set CLASSPATH=C:\Weblogic\Middleware\wlserver_10.3\server\lib\weblogic.jar


To deploy from your local desktop (remote):


To deploy a WAR file:
java weblogic.Deployer -adminurl <<admin server host:port>> -user weblogic -password ulorcl123$ -deploy C:\JDeveloper\mywork\myApp\deploy\myApp.war -remote -upload
To redeploy a WAR file:
java weblogic.Deployer -adminurl <<admin server host:port>> -user weblogic -password ulorcl123$ -redeploy -source C:\JDeveloper\mywork\myApp\deploy\myApp.war -remote -upload -name myApp.war


Common Errors:


Error:
'ModuleArchive' cannot be null
Resolution:
Make sure the source parameter is specified in the redeploy command

Hope you find this helpful! Please share your feedback below.
CaptiveCode


Saturday, January 21, 2017

TopLink - Common Errors - ClassCastException

Are you facing a class cast exception while using Oracle TopLink?
For example - com.entity.Organization cannot be cast to com.entity.Organization

In my experience, this issue occurred sporadically and was not consistent. The reason this occurs is because multiple instances of Entity Manager have been created in your application session. The class loader is hence unable to determine the instance of the class that is to be loaded

Here is how I was able to workaround the issue:

  • Create a listener class (myListner) as shown below
    • Override the contextInitialized method to create an entity manager as soon as the application session is initiated
    • Override the contextDestroyed method to release the entity manager as soon as the application session ends
  • This will ensure only a single instance of entity manager exists at any point in time. Thus, eliminating the root cause.


package com.db.dao;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class myListener implements ServletContextListener {
    private static String persistenceUnitName = "Persistent_Unit_Name";
    private static EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName);

    public myListener() {
    }

    @Override
    public void contextInitialized(ServletContextEvent event) {
        if (!emf.isOpen()) {
            emf = Persistence.createEntityManagerFactory(persistenceUnitName);
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent event) {
        if (emf != null) {
            emf.close();
        }
    }

}

  • Register the listener class in your web.xml
<web-app version="2.5" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns="http://java.sun.com/xml/ns/javaee" 
   xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
  <display-name>myTopLinkProject</display-name>
  <description>Sample TopLink Application</description>
  <filter>
    <filter-name>JpsFilter</filter-name>
    <filter-class>oracle.security.jps.ee.http.JpsFilter</filter-class>
    <init-param>
      <param-name>enable.anonymous</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>JpsFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
  </filter-mapping>
  <listener>
    <description>Web Application Listener</description>
    <display-name>myListener</display-name>
    <listener-class>ul.iam.db.dao.myListener</listener-class>
  </listener>
</web-app>





Hope you find this helpful! Please share your feedback below.

CaptiveCode


How To: Configure JTA Data Source in TopLink persistence.xml

Here is an example of a persistence.xml when using a data source:

<persistence version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns="http://java.sun.com/xml/ns/persistence" 
   xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="Sample" transaction-type="JTA">
    <description>Attribute Data Store</description>
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/SampleDataSource</jta-data-source>
    <properties>
      <property name="toplink.logging.level" value="INFO">
    </property></properties>
  </persistence-unit>
</persistence>





Please share your feedback below. Hope you find this helpful!

CaptiveCode


Saturday, September 17, 2016

How To: Launch Oracle Form (FMB/ D2K) from OAF Page

Given below is the code snippet to invoke Oracle Forms from OAF page. However, it can get tricky when you need to pass parameters. Read the use cases further below for illustrations.

Launch Oracle Form from OAF

1. Add a button or link on the OAF page using form personalization. Note if the ID of the button/link.
2. Extend the controller of the page and override the processFormRequest method as follows:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { 
 super.processFormRequest(pageContext, webBean);

 if (pageContext.getParameter("Go") != null) { 
  // form:APPLICATION_SHORT_NAME:RESPONSIBILITY_KEY:DATA_GROUP_NAME:FORM_FUNCTION_NAME
  String destination =  "form:FND:APPLICATION_DEVELOPER:STANDARD:FND_FNDPOMPO"; 

  //Invoke the Form
  pageContext.forwardImmediatelyToForm(destination);               
 } 
}


Use Case#1: Launch Oracle PO Form from OAF to Create PO

Edit the destination string as follows to launch the PO Form:

String destination = "form:PO:PURCHASING_OPERATIONS_AIG:STANDARD:PO_POXPOEPO";


Use Case#2: Launch Oracle PO Form (with Parameters) from OAF to Edit PO

The parameters for a given form vary. The below-listed parameters are specific to a PO form. For other FMB forms, I would recommend to download the FMB and review it Oracle Forms Builder so that you can identify the parameters you need to pass.
 
  /**
    * Parameters: 
    * PO_HEADER_ID 
    * = poHeaderId => This is the document ID
    * 
    * ACCESS_LEVEL_CODE 
    *  = MODIFY => This indicates to open the form in edit mode
    *
    * POXPOEPO_CALLING_FORM 
    * = OAF => This is calling function name. 
    *    If your OAF page is registered as a function, 
    *    provide the function short name here
    *
    * G_QUERY_FIND 
    * = FALSE
    *
    */
 
    String destination = "form:PO:PURCHASING_OPERATIONS_AIG:STANDARD:PO_POXPOEPO:" 
       + "PO_HEADER_ID=\"" + poHeaderID 
       + "\" " + "ACCESS_LEVEL_CODE=\"MODIFY\" " 
       + "POXPOEPO_CALLING_FORM=\"OAF\" " 
       + "G_QUERY_FIND=\"FALSE\"";
 
    pageContext.forwardImmediatelyToForm(destination);



Please share your feedback below. Hope you find this helpful!

CaptiveCode


Saturday, September 10, 2016

GIT: How to create empty branch in GIT?

Execute the following command on the GIT terminal:

#Create Empty Branch
git checkout --orphan branch_name

#Clear Working Directory
git rm --cached -r .

Please share your feedback below. Hope you find this helpful!

CaptiveCode


Tuesday, August 30, 2016

How To: Perform "Date Conversion" in ADF/ OAF/ JAVA

I run into the struggle of converting one data type to another all the time. And obviously, I don't recollect instantly how to convert one from another. So here's some notes for me & hopefully they will useful for you as well.

// 1. Get Date from Calendar 
 int year=2016; int month=1; int date=1;
 Calendar cal = Calendar.getInstance();
 cal.set(year, month, date);
 java.util.Date utilDate = cal.getTime();

// 2. Convert java.util.Date to java.sql.Date
 java.util.Date utilDate = new java.util.Date();
 java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());

// 3. Convert java.sql.Date to oracle.jbo.domain.Date
 java.sql.Date sqlDate = new java.sql.Date();
 new jbo.domain.Date(sqlDate);
 /* To get current date & time in jbo.domain.Date */
 java.util.Date utilDate = new java.util.Date();
 java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
 oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(sqlDate);

// 4. Convert java.util.Date to java.sql.Timestamp
 java.util.Date utilDate = new java.util.Date();
 java.sql.Timestamp timestamp_now = new java.sql.Timestamp(utilDate.getTime())

Please share your feedback below. Hope you find this helpful!

CaptiveCode

Thursday, August 25, 2016

OAF: CSS Classes for OA Components

Here is the link where all the OAF CSS classes for OA Components are published:
http://download.oracle.com/tech/blaf/specs/textstandards.html#general

 Do not go by the look and feel of this page. The CSS classes will reflect the look and feel of your EBS environment.

Please share your feedback below. Hope you find this helpful!

CaptiveCode

How To: Redirect to a new page in OAF

The method pageContext.setForwardURL() is to redirect to a new page. There are several ways in which the method can be used in your controller class:

Option 1:

 //Create HashMap to include destination page parameters
 HashMap hm = new HashMap();
 hm.put("poNumber",poNumber);
 hm.put("pMode","createMemo");

 //Forward to destination page
 pageContext.setForwardURL(
  "OA.jsp?page=/xxcc/oracle/apps/ar/demo/webui/myDemoPG", // Path to the destination page
  null,  // No need to specify with KEEP_MENU_CONTEXT
  OAWebBeanConstants.KEEP_MENU_CONTEXT, // No change in the menu context. Keep same as source page 
  null,  // No need to specify with KEEP_MENU_CONTEXT
  hm,  // HashMap with page parameter
  true,  //Retain AM state.
  OAWebBeanConstants.ADD_BREAD_CRUMB_YES, //Show breadcrumbs
  OAWebBeanConstants.IGNORE_MESSAGES //Ignore any messages
 ); 

Please share your feedback below. Hope you find this helpful!

CaptiveCode

How To: Remove all rows from view object (VO) in OAF & ADF

Option 1: 

The executeEmptyRowSet() method can be used to empty the VO. This is my preferred approach.
    /* Use the following snippet in the Application Module (AM) */
    OAViewObjectImpl vo = this.getMyDummyVO();
    vo.executeEmptyRowSet();

Option 2: 

Loop through the VO and remove each row. If the data set is too large this could be cost intensive. I do not prefer this option.
    /* Use the following snippet in the Application Module (AM) */
   OAViewObjectImpl vo = this.getMyDummyVO();
   while(vo.hasNext()){
      vo.next().remove();
   }

Please share your feedback below. Hope you find this helpful!


CaptiveCode


Wednesday, August 24, 2016

OAF: How to find the OAF Developer's Guide

The OAF Developer's guide is the bible for OAF developers.

The document 131548.1 has the OAF developer guides for all Oracle EBS versions until date.

Happy coding!

Let me know if you need help with something!

CaptiveCode

OAF: Create a new OA Workspace & Project

Follow these steps to create a new OA Workspace and Project:

Prerequisite:

  • Determine the version of the Oracle EBS environment. (Example: R12.2.4) 
  • Determine the JDeveloper version to be used for the corresponding EBS environment using Note 416708.1

1. Create OA workspace

  • Right click on Applications > Select New OA Workspace
  • Enter the Name of the Workspace (Example: Demo.jws) 
  • Select the Checkbox "Add New OA Project" 
  • Click Ok

2.  Create OA Project

  • On clicking ok, in the prior step the OA Project wizard should launch
  • Enter the Name of the Project (Example: myDemo.jpr)
  • Provide a default package if required (Example: com.myDemo)
  • Provide a design time DB Connection 
    • Select the checkbox Use Repository for Design Time
    • Select the DB Connection from DropDown OR Click New to create a new DB connection
  • Provide Run Time Configuration
    • ** This step is optional at this time but you will need to do this if you want to run your pages locally in JDeveloper **
    • Enter the following for each of the fields:
      • DBC File - This file can be obtained from the FND_TOP of the EBS environment.
      • Username - Enter the oracle apps username (Example: operations)
      • Password - Enter the oracle apps password (Example: welcome)
      • Responsibility Key - The responsibility key within which you want to run the page. (Example: APPLICATION_DEVELOPER)
      • Application - The application within which the responsibility is defined (Example: FND)


Please share your feedback below. Hope you found this helpful!

CaptiveCode


Monday, August 22, 2016

SQL: Create a new user/schema in Oracle

Use the following script to create a new user/schema XDUMMY. Run these scripts as the SYS user:

/* Script to create new user with username XDUMMY and password xdummy */

CREATE USER XDUMMY IDENTIFIED BY xdummy
DEFAULT TABLESPACE "TEMP"
TEMPORARY TABLESPACE "TEMP"
QUOTA 20M on TEMP;

/* Script to grant session and create privileges to new user */

GRANT create session TO XDUMMY;
GRANT create table TO XDUMMY;
GRANT create view TO XDUMMY;
GRANT create any trigger TO XDUMMY;
GRANT create any procedure TO XDUMMY;
GRANT create sequence TO XDUMMY;
GRANT create synonym TO XDUMMY;

/* Create new objects in schema */

// Connect to DB as as xdummy/ xdummy
create table dummy_tbl (...);

/* Create synonym so that you can query from other schemas */

create public synonym dummy_tbl for xdummy.dummy_tbl;

/* Query your objects from another schema. Example: APPS*/

// Connect to DB as as apps/<apps_pwd>
select * from dummy_tbl;





Please share your feedback below. Hope this is helpful!


CaptiveCode


Tuesday, August 16, 2016

SOA: Fault Handling: Creating a fault policy

Fault handling is a very interesting concept in SOA. It is analogous to Exception Handling per OOPs concepts.

Fault Policy is defined to handle runtime fault exceptions. You can define actions to execute based on the type of exception. Here's a 1-0-1 on defining a simple fault policy:

1 -  Create the fault-policies.xml file

Right Click on the Project > Select From Gallery > Select SOA Tier/Faults > Fault Policy Document > Click Ok

This creates a fault-policies.xml within the project/SOA folder.

2 - Editing the fault policy

Open the fault-policies.xml to edit the fault policy.

Provide a unique ID to the fault policy:
<faultPolicy id="MyFaultPolicy">

Let's define the fault policy to retry 3 time at a interval for 120 sec for any runtime fault:

<faultName>
    <condition>
        <action ref="ora-retry"/>
    </condition>
</faultName>

This means for any fault (since no name is specified) the action "ora-retry" will be executed. The action "ora-retry" is a custom action here. We will need to define what ora-retry means.

3 - Define ora-retry

Add the following action to the fault policy file.

<Action id="ora-retry">
    <retry>
        <retryCount>2</retryCount>
        <retryInterval>60</retryInterval>
        <exponentialBackoff/>
        <retryFailureAction ref="default-terminate"/>
    </retry>
</Action>

4 - Review the Fault Policy

Here is how the fault-policies.xml document looks:

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:medns="http://schemas.oracle.com/mediator/faults" xmlns:rjm="http://schemas.oracle.com/sca/rejectedmessages">
    <faultPolicy id="MyFaultPolicy">
        <Conditions>
            <faultName>
                    <action ref="ora-retry"/>
            </faultName>
        </Conditions>
        <Actions>
            <Action id="default-termination">
                <abort/>
            </Action>
            <Action id="ora-retry">
                <retry>
                    <retryCount>2</retryCount>
                    <!--<retryInterval>43200</retryInterval>-->
                    <retryInterval>60</retryInterval>
                    <exponentialBackoff/>
                    <retryFailureAction ref="custom-java-send-email"/>
                    <retrySuccessAction ref="default-termination"/>
                </retry>
            </Action>
        </Actions>
    </faultPolicy>
</faultPolicies>


5 - Create the Fault Bindings

Now the fault policy is created. However, the job is not done yet. We need to associate the fault policy to the composite. Thus, whenever there is a fault in the composite the fault policy "MyFaultPolicy" will be invoked.

To do this we need to create the fault-bindings.xml file within Project/SOA folder as follows:

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
    <composite faultPolicy="MyFaultPolicy" />
</faultPolicyBindings>




Please share your feedback below. Hope this is helpful!


CaptiveCode


Sunday, August 14, 2016

How To: Throw a custom fault/ exception in BPEL (SOA-Fault Handling)

Fault Handling in SOA is analogous to Exception Handling in OOPs. Below is how to throw a fault in a BPEL process:

1 - Define the fault message type

Add the RuntimeFault.wsdl to the Project/SOA/WSDLs folder. This WSDL contains the message definition of the fault that will be thrown at runtime.

<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="RuntimeFault" targetNamespace="http://schemas.oracle.com/bpel/extension"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/">
    <message name="RuntimeFaultMessage">
        <part name="code" type="xsd:string"/>
        <part name="summary" type="xsd:string"/>
        <part name="detail" type="xsd:string"/>
    </message>
</definitions>

2 - Define the fault variable to hold the fault

Define a new BPEL variable with the message type "RuntimeFaultMessage" created in the step above.

Variable Name: faultVar
Type: Message Type
Namespace: http://schemas.oracle.com/bpel/extension
Local Part: RuntimeFaultMessage

3 - Create a throw activity

Drag and Drop the "Throw" activity from the Components Menu into your BPEL process.

Activity Name: ThrowFault
Namespace: <Target Namespace of your BPEL process>
Local Part: <Name the Fault>
Fault Variable: faultVar (fault variable created in the step above)



Hope you find this information useful.Please share your feedback below. I would love to hear from you.

CaptiveCode