Wednesday, January 27, 2016

Solution to ADFC-0619: Authorization check failed

Problem Statement:
My ADF Application, with security implemented through jazn-data when deployed on Weblogic box, the authorization does not happen and i often i receive
oracle.adf.controller.security.AuthorizationException: ADFC-0619: Authorization check failed: 'oracle.jbo.uicli.binding.JUFormDef@d856cd' 'VIEW'.

This issue has been discussed @:
https://community.oracle.com/message/9646751
http://oracle.developer-works.com/article/4786269/ADFC-0619%3A+Authorization+check+failed%3A+'homePageDef'+'VIEW'+-+Solved

Root Cause:
The root cause for the issue is when an ADF application with security enabled is deployed through weblogic console the <Domain_home>/config/fmwconfig/system-jazn-data.xml do not get updated and hence the server is not aware of the security policies and the page remains unavailable

Solution:

I was stuck with this issue for more than 2 weeks and following solutions were implemented:

1. Instead of going for Authentication and Authorization go for Authentication only


Not sure why this works, but it induces a new issue.
Issue with this approach if if trying to access a page with permission given to anonymous-role, the application would route to the login page in this case and user is forced to login

2. Try to deploy the application on server through Jdeveloper


This solves the issue but in most of the cases the prod servers wont be available for developers to access and makes this approach unpractical

3. Deploy through em console

This approach finally worked in my case. Deploy the application on Admin Server through em console. Make sure in Deployment Settings: Click on Configure Application Security to modify the default settings and in Configure Application Security provide following:

Select Application Policy Migration as “Append”.
Uncheck the “Remove Policies during Application undeployment
Provide Application setting id as "<Application_name>"
Click Apply



NOTE: THIS STEP WOULD UPDATE THE system-jazn-data.xml FILE

Now undeploy the application from Admin Server and deploy it on the managed server with same settings keeping the system-jazn-data.xml intact(i guess deployment to managed server can be done even from WL Console but never tried it)

probably Dimitar Dimitrov speaks of the same stuff manually in the thread



Please share your thoughts on this issue if you face it




Wednesday, January 6, 2016

Solution to JBO-25014: Another user has changed the row with primary key oracle.jbo.Key[xxx].

I have posted this issue here

Simultaneous Commit operation in ADF throws "oracle.jbo.RowInconsistentException: JBO-25014"

Chris has discussed this issue in detail here

I have how tackled the solution and such implementation can be applied as turn around solution.

The real culprit is:

We know the record in the mid-tier has been changed by the user, however ADF doesn't use the changed record in the mid-tier to compare to the database record, but rather a copy of the original record before it was changed.  This leaves us to conclude the database record has changed, but how and by who?

So,  simple call execute operation for that viewObject after commit would solve the problem .
as:            
   OperationBinding op = getBindings().getOperationBinding("searchApplication");  //searchApplication is the method which populates the VO
    op.execute();

But would reset the iterator and even though the selected row in table is (says 5th from the top), the form would be always displaying 1st row.

So i deal with problem with variable defined as:
private String currentRowKeyStr="";
i would set this variable to
currentRowKeyStr=row.getAttribute("PrimaryKeyValue")!=null?row.getAttribute("PrimaryKeyValue").toString():"";

Similarly,
on the table selection listener
selectionListener="#{pageFlowScope.Bean.selectTable_SelectionListener}"

i would set this variable every time a row is selected as:
currentRowKeyStr=rowSelected.getAttribute("PrimaryKeyValue")!=null?rowSelected.getAttribute("PrimaryKeyValue").toString():"";

Please post comment in case you need help with such issue

Wednesday, December 23, 2015

Fixing the Issue where getBindings() returns Null

Problem Statement:

Suppose we have a jspx page having a bounded task flow as region.


The taskflow starts with method activity as shown in the figure


If the method tries to access the some method binding using the getBinding() method, where get binding is defined as:

    public BindingContainer getBindings() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }

some binding method accessed as:
        OperationBinding op =
            (OperationBinding)getBindings().get("someMethodInAppModImpl");
        Object result = op.execute();

in this case, the BindingContext.getCurrent() would return the BindingContext but when trying to access getCurrentBindingsEntry(), this method would return null and as result the
 OperationBinding op =
            (OperationBinding)getBindings().get("someMethodInAppModImpl");

would throw null pointer exception

Solution:

Since the page starts with method having no pagedef difination the CurrentBindingsEntry always return null.

Make Sure you create binding for the default method as:


also the binding defined for the method shall have the method binding for the someMethodInAppModImpl you wish to access during execution.

Once page defination is defined, you can see the small little sign at the right bottom of the methodas


Please reach out in case of any further issues


Tuesday, July 14, 2015

Externalized Resource Bundle for ADF Application

Often we have to use resource bundle for our project which is a part of the project war.
Issue with this approach is when the war is specific to environment, for eg, if you need to provide different url for dev,prod,st and qa in your application, you need to create environment specific artifact and the same artifact can not be implemented across all the environment.

Solution to this approach is to externalize the resource bundle. The resource bundle would be the part of environment and the application would point to the location of the resource bundle instead of resource bundle being a part of the Application.

steps to implement the same:

1. create the property file with content(content is specific to this demo):

button_value=this text comes from property file
butoon_message=this message will be displayed on button click which comes from property file

and save it as TestMessage.properties in the local folder for eg:

C:\test\TestMessage.properties

while deploying the application in weblogic the path can be:
/web/TestMessage.properties

2. Mention the path's name in weblogic's start parameter.
I would define a system variable as TESTPROP_PATH and assign it the location as C:\test\TestMessage.properties for the example

To achieve this i have made an entry in
setDomainEnv file present in <UserFolder>\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\bin

as:
set EXTRA_JAVA_PROPERTIES=-Djps.app.credential.overwrite.allowed=true -DTESTPROP_PATH=/test/TestMessage.properties %EXTRA_JAVA_PROPERTIES%

once set, this variable can be accessed from application as:

System.getProperty("AIMSPROP_PATH")

***please check with Environment team how to perform the step 2 for the environment


3. Now in your application you need to create a java class which would extend ListResourceBundle and fetch all the entries from the file as:

4. Make an entry for this class as <resource-bundle> in faces-config.xml

5. To access the resource bundle in jspx or jsff and entry has to be made in for f:loadBundle and can be used as:
6. Similarly, to use the resource bundle in java class can be used as:

the link to the demo application can be found here

steps 1 & 2 has to be performed individually to run the downloaded application


Please put in your comments in case of any doubts or suggestion to improvise this entry

Wednesday, February 4, 2015

Integrate your jdeveloper with FindBug Utility

FindBugs is an useful open source program which looks for bugs in Java code.It uses static analysis to identify hundreds of different potential types of errors in Java programs.Reports from find bug comes very handy when trying to sanitize your application code before moving to a production like environment. I took the help from link to use it as tool within my local jdeveloper. I will explain the same as step by step integration.

1. Download find bug zip from mentioned link, unzip it and place it in your local
2. Write the following xml file to use as ant build file  later

<?xml version="1.0" encoding="windows-1252" ?>
<project xmlns="antlib:org.apache.tools.ant" default="init">
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
  <target name="init">
    <tstamp/>
  </target>
  <property name="findbugs.home" value="C:/HPP/findbugs-3.0.0/findbugs-3.0.0" />
  <target name="findbugs">
    <findbugs home="${findbugs.home}" output="text">    
      <sourcePath path="${basedir}/src/java" />
      <class location="${basedir}/classes" />
    </findbugs>
  </target>

</project>

for this example saving the file as findbug.xml 

3. Now lets start with creating an external tool in jdeveloper. Go to Jdeveloper -- > Tool -- >External tool --> New
4. Select Apache Ant as Tool Type

5. Select the findbug.xml saved in step to as Ant buildfile

6. select findbugs as available target 

7. As mentioned in the build file, it expects a parameter named basedir which has to be added as project directory in this case


8 go with default options for options and process step


9. Make sure you point to findbug-ant.jar(available as<findbug_home/lib/findbug-ant.jar>) as class path entry


10. I am selecting it as Tool Menu in this case and making the availability as always


11. Select your project (either model or view, one at a time) and select FindBug from one of the option in Tool menu to generate the report


Please comment in case of any issues

Edit #1 : Findbugs 3.0 will work only with JDK 1.7. Choose the same in step 8


Friday, August 15, 2014

af:inputDate Validation

The mentioned example demonstrates how to implement specific validation for the af:inputdate component.

Use Case: Application expects the entered date to be atleast 18 Years from current date

jspx code:
<af:inputDate value="#{bindings.Dob.inputValue}"
                          label="Date Of Birth" autoSubmit="true"
                          shortDesc="#{bindings.Dob.hints.tooltip}" id="id1">
              <f:validator binding="#{bindings.Dob.validator}"/>
              <af:convertDateTime pattern="#{bindings.Dob.format}"/>
              <af:validateDateTimeRange maximum="#{pageFlowScope.BackingBean.userDOBMax}"/>
              <af:convertDateTime hintDate=" " messageDetailConvertDate=" "/>
     </af:inputDate>


Here the af:validateDateTimeRange  is binded to backing bean method named userDOBMax which is defined as follows:

    public Date getUserDOBMax() {
        Calendar now = Calendar.getInstance();
        now = Calendar.getInstance();
        now.add(Calendar.YEAR, -18);
        return now.getTime();
    }

specific validations can be implemented as per the requirement

Tuesday, July 8, 2014

Implementing Auto Suggest in ADF

Took help from http://www.oracle.com/technetwork/developer-tools/jdev/autosuggest-090094.html
Requirement is to auto suggest users while using input field . In this case, there is an inputbox for employee's first name (using the HR schema) where upon entering the character, popup suggests user for the list of employees with the first name starting with the character entered as shown in the figure.


View Layer:
1. Create a jspx page with input box, and add the clientListener attributes to the input box

2. define the af:popup segment in the jspx with selectOneListbox option. Function written on keyup and click of input box would populate the List box in this case

Model Layer:
1. Create the EmployeeVO with View Criteria as:


    and write the java method to populate the Employee List(can be found in the code attached)
2. The backing bean would fetch the List from AppMod using method binding:


Run the jspx and result would be as expected :)


Code can be found @ Auto Suggest