Sunday, February 25, 2018

Deploy ADF Application to Oracle Cloud


To deploy your Oracle ADF Application to the Oracle Cloud:

Create Oracle Cloud Account from

https://cloud.oracle.com/en_US/home

 Click on "Try For Free"

Enter a name for "Cloud Oracle  Name" , country , Region and your Email.

An Email will be sent to your Email with login details 

( remember your cloud account name and the temporary password for login )


Login with your Cloud Account Name from here
https://cloud.oracle.com/en_US/sign-in

 click on "My Services" button , then a  new tab is opened

 Enter Your Email Address and the temporary password for login to your services 

Click on the menu navigator then click on "Database" under "Services" to create new database instance.

Click on "Create Instance"

 1.     Choose an instance name then click next (Ex. MASSDATABASE).


Click Edit button beside the "SSH Public Key" field

Choose "create new key" radio button and click "enter" button.

 A new popup appears , click on "Download" button download a zip file that contains a  three files publickey , privatekey and service_credentials.txt .
Note that file "service_credentials.txt" is a text file contains the following line in a plain text format:
Password (to access DBCS): XJFRIFF_VR

fill the remain fields.remember the "administration password" (you will need it to connect to the database)
then click next 


A summary of the instance is shown before starting creating the database instance.

( Remember your PDB name and port number that you will need for connecting to the database.


The available database services appears
( note: The new database instance status is "Creating instance..." ,
The Storage number and public IPS is increased.).

Wait about 25 minutes to be created , meanwhile you can create another service if you need.
 You can see the status of all your services by click on the upper right menu navigator and click on "Platform Services".


You can see from here your database instance status with other different services status , click on the refresh icon to keep track of the new status.


When the "created on" date field shown ,it means that the database creation is done.

Click on the menu navigator beside your new database instance then click "Access Rules" button.

Enable the rule with name: ora_pr_dblistener and ora_p2_dbconsole
( note that the icon is changed after enable ). 


click the link "Oracle Database Cloud Service" to return to database instances page

When the "created on" date field shown means that the database creation is done.
Click on your database instance name which is link to get the connection string


(Remember the "Public IP" field and "Connect String").


Copy the Public IP and the connect string, then open JDeveloper.



Create new connection and click test


Next You will need to create weblogic server cloud  instance (Oracle Java Cloud Instance) to deploy the application to it.

Thursday, February 15, 2018

Exception: Scope object serialization failed (object not serializable)

A common reason for the "SEVERE: ADFc:Scope object serialization failed (object not serializable)" error message is that :
application developers reference JSF components in managed beans with a scope larger than request.

When using the JSF component Binding property to point to a managed bean, think backing bean and thus don't reference beans that are in scopes larger than request scope (so don't: use viewScope, pageFlowSope, sessionScope or applicationScope).
If, from a managed bean in a scope larger than request you need to have access to a component instance (though the other way around is a more common use case) then either
- look up the component on the UIViewRoot.

- resolve an EL reference to a managed bean in request scope that holds the component binding.

This article contains more details and other important subjects :
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/may2012-otn-harvest-1652358.pdf


Saturday, February 10, 2018

google json library to convert from and to json

Google Gson is an open source  java based library developed by Google.
It facilitates serialization of Java objects to JSON and vice versa.

import com.google.gson.Gson;
import java.util.HashMap;
import java.util.Map;
public class FormToGson {
    public FormToGson () {
        super();
    }
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("Name", "Mahmoud");
        map.put("Job", "DEV");
        Gson gosn = new Gson();
        String paramsJsonString =  gosn.toJson(map);
        System.out.println(paramsJsonString);
       
        HashMap map2 = gosn.fromJson(paramsJsonString, HashMap.class);
        System.out.println(map2.get("Name"));
    }
}
This can be helpful when calling a servlet for example to print a jasper report you will pass only one query parameter that holds the json object as a string from the bean class :
 /Servlet?params=paramsJsonString .

To downlaod the jar:

https://mvnrepository.com/artifact/com.google.code.gson/gson




java - fill distinct objects in ArrayList

If you have a list that contains some objects that it is considered as duplication when two or three fields of these objects are equal. How ...