Skip to Main Content

Cloud Platform

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Building and Testing Databound Web Applications using JCS, DBCS and JDeveloper 12c

Bob Rhubart-OracleSep 24 2015 — edited Feb 16 2016

The Cloud has become an integral part of the IT Ecosystem. Organizations are moving their huge physical IT infrastructure to the Cloud for better governance, lower TCO and better ROI. This article showcases the simplicity of using Oracle Java Cloud Service (JCS), Oracle Database Cloud Service (DCS) and JDeveloper 12c to develop, deploy and test Web Applications


By Kumar Shahi

Highlights of this article:

  • How JDeveloper 12c eases the development of ADF Web Application
  • How JDeveloper 12c easily connects with JCS for smooth deployment
  • How SQL Developer easily connects to DCS and simplifies DB operations
  • No need to have a physical IT infrastructure to host your application as it uses JCS to host application
  • Access to diagnostic logs to have better monitoring and application testing

This article covers:

  • Creating a simple DCS for hosting Application Schema
  • Creating Data Source in JCS to have access to DB Tables and data
  • Developing simple data-bound ADF Web Application using Jdeveloper 12c
  • Deploying and Testing Web Application on JCS
  • Accessing Diagnostic Logs via Putty

Pre-requisites:

  • JDeveloper 12c (12.1.3.x)
  • Latest Oracle XE Database
  • SQL Developer 4.1 (with JDK 8)
  • Oracle Cloud Access (JCS and DCS)
  • Public/Private Key Pair to be used for account setup
  • HR Schema DDL
  • Putty

Use Case

I have taken a simple use case of creating an HR Application to show and modify employee information.

In this exercise,

  1. Create Database Cloud Service

  2. Connect DCS using SQL Developer

  3. Set up HR User in DCS, create tables and populate data

  4. Develop HR Application using JDeveloper 12c

  5. Create datasource in JCS to connect HR Schema

  6. Set up Putty to tunnel JCS connection

  7. Set up JCS Connection using JDeveloper 12c

  8. Deploy HRApplication to JCS using JDeveloper 12c

  9. Access diagnostic logs using Putty

Solution

Create Database Service

Log in to Oracle Cloud Service at https://myservices.oraclecloud.com/mycloud/faces/gDashboard.jspx

login
Supply Identity Domain, User Name, User Password and Sign In.

This dashboard page will open:

dashboard

Click "Open Oracle Database Cloud Service" to open the page below:

dbaas

Click the “Create Service” button to create a new Oracle Cloud Database Service. The page below will open. Select Service Level.

The first option, Oracle Database Cloud Service, will be enabled only if the associated Oracle Cloud Storage Account has a container created and available.

Otherwise, choose the Oracle Database Cloud Service-Virtual Image option.

dcs_servicelvl.png

Billing Frequency needs to be specified even if you have a trial account. I have selected “Monthly."

Click “Next.” You'll see this screen, where you can specify the database version:

dbaas2

Click “Next” and select your Software Edition. I have selected Enterprise Edition.

dbaas3

Click “Next.”

dbaas4

Assign values to the required attribute:

  • Service Name – Specify Database Cloud Service Name
  • Compute Storage – Select configuration you would like to use
  • VM Public Key – Supply Public Key (created as part of prerequisite)
  • Usable Database Storage – Specify storage requirement for the database service
  • Total data file storage – Specify total data file storage
  • Administration Password – Specify Password for the SYS user
  • Confirm Password specified above
  • DB (Database) name – Automatically populated. User can modify if required.
  • PDB (Pluggable Database) Name – Automatically populated. User can modify if required.
  • Backup destination – The “Both Cloud and Local Storage” option will be available only if container is configured. Otherwise, user can select “Local Storage Only.”
    If backup destination is “Both Cloud and Local Storage,” user will have to supply:
    • Cloud Storage Container – e.g., identityDomainName/containerName
    • Cloud Storage User name – cloud admin user name (normally email id)
    • Cloud Storage Password – cloud admin password.

Click “Next.” Confirm on the landing page to start creation of DBaas Service.

Database Cloud Setup Progress

It may take a few minutes to set up Database Cloud Service. Click “Service Name” to see the list of activities being performed.

Connect Database Service using SQL Developer

This requires two steps: Setting up SSH and Creating New Database Connection.

Setting up SSH

Start SQL Developer 4.x.

sqldeveloper

Open the “View” menu and click “SSH”. It will open the SSH Panel in SQL Developer.

sqldeveloper-ssh

Right click “SSH Hosts” and add “New SSH Host”:

sqldeveloper-ssh1

In the above screen, specify attribute values as given below:

      **Name –** Specify Name of your choice. (Tip: Specify name based on Oracle DB Cloud Service Name so that it will be easy to remember.)

      **Host –** Host must be the Public IP of Oracle Database Cloud Service

      **Port –** Leave as 22

      **User Name** – Must be **oracle**
  • Check “Use Key File” checkbox and browse “Private Key file” generated as part of prerequisite.

Check “Add a local port forward" to set Local Port Forward details as below,

      **Name - S**pecify any Name of your choice

      **Host –** Must be Public IP of Database Service

      **Port –** Port specified for your Database Service (e.g., 1521)
  • Check “Automatically assign local port”

Now, right click on this new SSH Host and click “Connect.”

Creating New Database Connection

Go to “Connections” and right click “New Connection”:

sqldeveloper-newcon

You'll see this screen, where connection details will be supplied:

sqldeveloper-newcon1

In the above image, specify properties as given below:

Connection Name – Specify any logical name

User Name – The Administrator User Name specified while setting up Oracle Cloud Database Service, e.g. SYS.

Password – Password specified for the Administrator

Select Connection Type – SSH

Role – SYSDBA

Port Forward – When you select Connection Type = “SSH,” Port Forward will list the “SSH Host Name” you created. Select SSH Host Name set up as part of "SQL Developer SSH Setup."

Specify SID – Generally, ORCL (unless you changed it)

Click the “Test” button. You'll see “Success.”

Click “Save” to save this connection and use it just like another DB connection.

Setting Up HR Schema

Open the SQL worksheet and run the commands below:

hrschema.png

Create a new Database Connection using c##hr user. Follow the same steps as you followed in "Creating New Database Connection," above, except specify Role = Basic.

Set up HR Schema using HR_30.sql, which can be downloaded from the location below. Recompile Triggers if it throws any error.

Download HR Schema from:

http://www.oracle.com/technetwork/developer-tools/datamodeler/sample-models-scripts-224531.html

Extract zip file and run SQL to set up HR Schema.

Scripts to load data can be found in the attachment of this article. Alternatively, you can export data from your local HR Schema and use those scripts.

Loading data into tables

Disable Trigger SECURE_EMPLOYEES (it validates against normal office hours to insert/update employee data). Run scripts in the following sequence:

regions.sql

countries.sql

locations.sql

jobs.sql

Disable constraint DEPT_MGR_FK from DEPARTMENTS Table before running departments.sql:

departments.sql

employees.sql

job_history.sql

Enable constraint DEPT_MGR_FK from DEPARTMENTS Table again.

Creating HRApp Web Application

Open JDeveloper 12c. Select "New"->"Applications"->"Fusion Web Application", Click OK.

1.png

Specify Application Name "HRApplication" and Application Package Prefix "com.hrapp":

2.png

Continue with default options until you reach the page depicted below and Click "Finish". It will create HRApplication ADF Web Application.

3.png

Create Business Objects using HR Schema. Right Click on "Model" Project and select "New":

Select "Business Components from Table" and click "Next". It will open "Create Database Connection."

Remember, the connection above is made to a local instance of HR Schema installed on my local machine.

Create a new connection with the name "hrconn," with access credentials as below:

5.png

In the next step, the newly created connection will be automatically selected. Select "OK":

6.png

Hit "Auto Query" to list available entities.

Select Employee and Departments table from available entities and move them to selected pane as given below.

Rename default package name "com.hrapp.model"(As displayed in below image) to "com.hrapp.entities".

Select each table name and rename their Object Name to EmployeesEO and DepartmentsEO respectively and select "Next".

7.png

Move all available entities to selected pane.

Rename default view package to "com.hrapp.views" as shown below.

Select each entity and change their name from,

 "DepartmentsEOView" to DepartmentsVO

  and "EmployeesEOView" to EmployeesVO

 then click "Next".

8.png

Continue with default selection until you reach the "Application Module" page. Rename AppModule Name "HRAppModule" and the package name to "com.hrapp.services" and then Select "Finish".

The Model Project will look like the figure, below, where all entities, View Objects and an App Module will be created. There is a default DataControl also created to access services.

10.png

Create Web Page to display Employee Data and Modify information.

Select "View Controller" Project ->Web Content" -> "New":

11.png

Select "JSF Page" from the dialog and Click "OK."

You'll see the popup below. Specify File Name = "empDetail.jspx", Document Type="JSP XML" and Page Template = "Oracle Three Column Layout." Click "OK."

12.png

It will create empDetail.jspx page.

Select the "End" section from the "Structure" panel and delete it.

Expand "HRAppModuleDataControl" and drag "DepartmentsVO1" to the "Facet Start" section and create as ADF Form.

Remove "Employee ID" from the display list and Select "Navigation Button" check box from the dialog box.

Click "OK."

13.png

Select "Facet:Center" and add "Panel Splitter" to "Facet:Center."

Expand "Panel Splitter -> Start."

Drag "DepartmentVO1"-> "EmployeeVO3" to "Panel Splitter->First" section, and drop as Read-Only Table.

Drag "DepartmentVO1"-> "EmployeeVO3" to "Panel Splitter->Second" section, and drop as ADF Form.

It will look like this:

center.png

Select "Single Row" to allow single row selection in table.

Check "Enable Sorting" to enable Sorting of data based on each columns ascending/descending.

Check "Enable Filtering" to enable filtering records using column filter.

14.png

Surround Departments ADF Form, Employees ADF Form and Employees ADF Read-only Table with ADF Panel Box.

Change Panel Box names to,

"Departments" for Departments ADF Form,

"Update Employees Information" for Employees ADF Form

and "Employees List" for Employees ADF Read-only Table respectively.

Select af:PageTemplate from empDetails.jspx - Structure Panel. In the Property Inspector window, change "Start Column Size" to 350.

Select "Save All."

Create Datasource for Web Application

Log in to JCS.

Open the Service Console, as shown below,

Open the WebLogic Server Console from here.

In the left panel, click "Services," then "Data Sources." Click “Lock & Edit” to enable “New” Button.

jcsdsn

Then click “New->Generic Data Source.”

ds1.1.png

Name = use any logical name

JNDI Name = This could be anything (I have specified “jdbc/hrds” and Oracle Database Cloud Service Name)

Database Type = Oracle

Click “Next.”

dsn2.png

On the next screen, "JDBC Datasource Properties," simply click "Next."

ds2.png

The "Transaction Options" screen will open. Click "Next;"

ds3.png

Enter details as mentioned in below screen,

Database Type = Oracle

Database Driver = As specified above. You can choose these setting based on your DB and driver.

On the next screen, “Simply click “Next”. It will open the screen below:

Database Name = ORCL, unless you changed it while creating database Cloud Service Instance

Host Name = Enter your Database Cloud Service name

Port = 1521

Database User name = c##hr (HR Schema user name)

Password = Welcome#1 (specified for HR Schema)

Click “Next.”

dsn3.png

On the next page, click “Test Configuration.” It should be a success.

If it doesn't show successful then re-verify the credentials supplied for database connection. Also make sure that network connection is there to connect to Database Cloud Service.

dsn4.png

Select Managed Server Name "kumarjav_server_1" and Click “Finish."

dsn5.png

Set Up SSH for Java Cloud Service

Make sure you have set up Oracle Java Cloud Service.

Start Putty by clicking on putty.exe

jcsssh

Specify Host Name – Public IP of Oracle Java Cloud Service Instance

Make sure Connection Type = SSH

Specify Saved Session name = Any name (it's best to use a meaningful name based on IP/Service connected)

Expand “Connections from left panel and select “Data,” as shown below:

jcsssh1

Login details > Auto-login username =

Comments

807575
There is not enough data yet for me to tell whether this is a Sun Studio compiler bug, invalid code that happens to be accepted by g++, or something else.

Please show the declarations for
vtkOpenGLExtensionManagerFunctionPointer
__GLXextFuncPtr
GLubyte
fname
807736
clamage45 wrote:
There is not enough data yet for me to tell whether this is a Sun Studio compiler bug, invalid code that happens to be accepted by g++, or something else.
as i already said, i'm a dev, i only get the tarball here:
http://www.paraview.org/files/v3.4/paraview-3.4.0.tar.gz

to reply to you as fast as possible, the complete log is available here:
http://www.latp.univ-mrs.fr/~henry/Solaris/x86/MAKE6.LOG

the file concerned is ./ParaView-3.4.0/VTK/Rendering/vtkOpenGLExtensionManager.cxx

i'm unable to give you a short example to highlight the behaviour of sunstudio.

thanks for your help,

gerard
807575
I can't debug large applications like this for you. I can evaluate compiler bugs.

I tried the compilation line that failed, substituting the path where I unpacked ParaView for your path, but some files come up missing.

Please run the CC command that failed, but substitute -E for the -c option, and redirect all output into a file. Example:
CC <options> vtkOpenGLExtensionManager.cxx -E >& vtkOpenGLExtensionManager.i
Move the .i file to a an empty directory, and try to compile it as
CC -c vtkOpenGLExtensionManager.i
You should see the same error messages. If so, post your email address here, and I'll tell you where to send the file.
807736
here are what i obtain:
henry@ultra20:/tmp/toot$ CC -c vtkOpenGLExtensionManager.i
"vtkOpenGLExtensionManager.h", line 140: Error: In this declaration "vtkOpenGLExtensionManager" is of an incomplete type "VTK_RENDERING_EXPORT".
"vtkOpenGLExtensionManager.h", line 140: Error: "," expected instead of ":".
"vtkOpenGLExtensionManager.h", line 144: Error: vtkOpenGLExtensionManager, of type int, was previously declared VTK_RENDERING_EXPORT.
"vtkOpenGLExtensionManager.h", line 144: Error: Multiple declaration for vtkOpenGLExtensionManager.
"vtkOpenGLExtensionManager.h", line 144: Error: "," expected instead of "*".
"vtkOpenGLExtensionManager.h", line 145: Error: ostream is not defined.
"vtkOpenGLExtensionManager.h", line 151: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 155: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 160: Error: ExtensionsString is not defined.
"vtkOpenGLExtensionManager.h", line 164: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 170: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 179: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 187: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 257: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 259: Error: A declaration was expected instead of "protected".
"vtkOpenGLExtensionManager.h", line 260: Error: Multiple declaration for vtkOpenGLExtensionManager.
"vtkOpenGLExtensionManager.h", line 261: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 261: Error: Type name expected instead of "vtkOpenGLExtensionManager".
"vtkOpenGLExtensionManager.h", line 261: Error: Illegal number of arguments for ~file level().
"vtkOpenGLExtensionManager.h", line 263: Error: Template vtkWeakPointer is not defined.
"vtkOpenGLExtensionManager.h", line 268: Error: vtkTimeStamp is not defined.
"vtkOpenGLExtensionManager.h", line 270: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 277: Error: "virtual" is not allowed here.
"vtkOpenGLExtensionManager.h", line 279: Error: A declaration was expected instead of "private".
"vtkOpenGLExtensionManager.h", line 280: Error: ")" expected instead of "&".
Compilation aborted, too many Error messages.
my email is ghenry_at_cmi.univ-mrs.fr

thanks for your help,

gerard
807575
I'm taking this discussion off line for now.
807575
Here are the results of my investigation.

The code in ParaView is actually invalid, but is accepted by g++.

The code in question when stripped down looks like this:
typedef unsigned char GLubyte;

typedef void ( * __GLXextFuncPtr ) ( void ) ; // implicitly extern "C++"
extern "C" {
typedef void ( * vtkOpenGLExtensionManagerFunctionPointer ) ( void ) ;
}

extern "C"
__GLXextFuncPtr  vtkglX :: glXGetProcAddressARB ( const GLubyte * ) ;


vtkOpenGLExtensionManagerFunctionPointer
vtkOpenGLExtensionManager :: GetProcAddress ( const char * fname )
{
    // ...
    return static_cast < vtkOpenGLExtensionManagerFunctionPointer >
    ( glXGetProcAddressARB( reinterpret_cast< const GLubyte* > (fname) ) ) ;
}
This code fragment is not compilable since some declarations are missing, but it shows the error.

In the return statement, the return value of glXGetProcAddressARB is converted via a static cast to type vtkOpenGLExtensionManagerFunctionPointer. The problem is that glXGetProcAddressARB returns a pointer to an extern "C++" function, but type vtkOpenGLExtensionManagerFunctionPointer is a pointer to an extern "C" function. The two function kinds are not compatible.

g++ incorrectly allows the conversion via a static_cast. Sun C++ and another compiler I tried do not allow it.

The simplest fix is to change the static_cast to a reinterpret_cast, which allows this kind of pointer conversion.

But on a system where C and C++ functions have different calling sequences, the code would not run correctly even if it compiled. I do not know of any such systems currently, but I would not be surprised to see some.

The correct fix is to match up the C and C++ function types, or to use proxy functions to convert between C and C++ function declarations. The C++ Migration Guide in section 3.11 discusses this topic in detail, with examples.
http://docs.sun.com/source/819-3689/Ch3.Std.html#pgfId-18041
1 - 6

Post Details

Added on Sep 24 2015
3 comments
7,293 views