Wednesday, December 11, 2013

Issue creating Connection Pool for Oracle on Glassfish3


As part of ADF Essentials setup on Glassfish, you need to create JDBC Pool. This is documented on http://docs.oracle.com/middleware/1212/adf/ADFAG/ap_glassfish.htm#ADFAG20931.

First make sure that you copy ojdbc6.jar to your Glassfish servers's domain-home\lib folder.

C:\glassfish3\bin>asadmin
Use "exit" to exit and "help" for online help.
asadmin> create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property user=user1:password=welcome1:url=jdbc:oracle:thin:@localhost:1521:XE SampleDSPool
remote failure: Invalid property syntax, missing property value: oracleInvalid property syntax, missing property value: oracle
Usage: create-jdbc-connection-pool [--datasourceclassname=datasourceclassname] [--restype=restype] [--steadypoolsize=8] [--maxpoolsize=32] [--maxwait=60000] [--poolresize=2] [--idletimeout=300] [--initsql=initsql] [--isolationlevel=isolationlevel] [--isisolationguaranteed=true] [--isconnectvalidatereq=false] [--validationmethod=table] [--validationtable=validationtable] [--failconnection=false] [--allownoncomponentcallers=false] [--nontransactionalconnections=false] [--validateatmostonceperiod=0] [--leaktimeout=0] [--leakreclaim=false] [--creationretryattempts=0] [--creationretryinterval=10] [--sqltracelisteners=sqltracelisteners] [--statementtimeout=-1] [--statementleaktimeout=0] [--statementleakreclaim=false] [--lazyconnectionenlistment=false] [--lazyconnectionassociation=false] [--associatewiththread=false] [--driverclassname=driverclassname] [--matchconnections=false] [--maxconnectionusagecount=0][--ping=false] [--pooling=true] [--statementcachesize=0] [--validationclassname=validationclassname] [--wrapjdbcobjects=true] [--description=description] [--property=property] jdbc_connection_pool_id
Command create-jdbc-connection-pool failed.

This kept failing for me, as it seems to parse URL for properties as URL has : character. Modifying the command as shown below resolved the issue. Notice URL is not specified as URL="jdbc\:oracle\:thin\:@localhost\:1521\:XE".

C:\glassfish3\bin>asadmin create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property user=user1:password=welcome1:URL="jdbc\:oracle\:thin\:@localhost\:1521\:XE" SampleDSPool
JDBC connection pool SampleDSPool created successfully.
Command create-jdbc-connection-pool executed successfully.


Sunday, November 24, 2013

Getting Started with ADF Mobile

At Fusion Development User Group even in Milwaukee, there was a general question on Getting Started with ADF Mobile. I am sure Google can find all this, but here is quick blog on Getting Started with ADF Mobile.

Development Environment

  • Use JDeveloper 11.1.2.4 with ADF Mobile Extension
  • You must use Mac for iOS testing and development. iOS Simulator works fine for testing and debugging.
    • Enroll in iOS developer program.
  • Download and Install Android SDK for Android build and testing. 

Examples

Learning Videos

Blogs


Java Source for JDK classes in JDeveloper 12c

If you try to open standard Java class from JDK in JDeveloper 12c, you will notice that it does not open Source.


This happens as there is no JDK 7 source included in default installation. You can see this by using Tools - Manage Libraries menu. Select Java SE Definitions tab, you will notice there is no Source Path.


You can first download JDK 7 Source from http://sourceforge.net/projects/jdk7src/files/jdk7u9/2012-10-27/. Download src-jdk.zip file and place it in oracle_common/jdk folder as shown below.


Now go back to JDeveloper. Go to Java SE Definitions under Tools - Manage Libraries. Select 1.7.* definition under User (not under Extension), and add src-jdk.zip to Source Path. JDK definition under Extension is Read Only, but when you restart JDeveloper after this change, Source Path will be updated for Extension JDK as well.


Now restart JDeveloper. You will now see source for JDK 7 java classes.


Tuesday, October 8, 2013

Integrate Quartz with ADF

In this blog entry, I will explain how to use Quartz to execute Background Jobs, where Jobs will eventually execute ADF Application Module methods.

I will be using JDBC Store for Quartz, which will allow me to execute jobs in Cluster environment. In addition, I have also included a Job Listener that will update job execution status in database table, which will help integrate with External Scheduler systems. Many companies have Enterprise Schedulers that control Jobs across various systems. Most of the time, these Enterprise Schedulers would call Shell scripts, and even if they can invoke Web Services, it is better to setup Asynchronous execution to avoid time outs. This approach will also be useful if you don't have an Enterprise Scheduler, in which case Quartz can act as your master scheduler.

1. Install Quart Libraries (1.6.4) in JDeveloper
  • Download - "myextensionsV2.zip".
  • Unzip downloaded myextensionsV2.zip in c:\temp.
  • Using command prompt, go to c:\temp\myextensions.
  • First set JDEVELOPER11_INSTALL_HOME environment variable, which should point to your JDeveloper installation. For example, set JDEVELOPER11_INSTALL_HOME=c:\jdeveloper
  • You can now run setup.bat file to install Jersey Library in your JDeveloper installation.

2. Create Scheduler tables
  • Download quartz-base.sql and quartz-myextension.sql.
  • Create SCHEDULER user using welcome1 password.
  • Create Database Objects using quartz-base.sql and quartz-myextension.sql.
  • This will create necessary tables for Quartz and my extension table for Job Listener.
3. Run JDeveloper Application
  • Download - Example3.zip
  • Unzip Example3.zip and Open using JDeveloper (11.1.1.7.0)
  • Perform Make All using Build menu.
  • Run MyDummyServlet. This is just to start Embedded WebLogic Server.
  • As Server starts, it will also start Quartz Scheduler, which is configured by QuartzInitializerServlet in web.xml.
  • When application and scheduler is started, you will see a new row in SCHEDULER.MY_SCHEDULER_STATE table.
  • Run ExecuteJob.java. This will schedule a Job in database, which will be picked up by running Quartz Scheduler in Embedded WebLogic Server.
  • You will notice output message in console.
  • While job is running, monitor SCHEDULER.MY_JOB_LISTENER table, you will notice State column value will change as Job State changes from Executing to Complete.
4. Next Steps
  • You can create proper implementation of ExecuteJob.java. For example, 
    • supply Input parameters to Job, using JobDataMap.
    • Poll MY_JOB_LISTENER for Status of Job - complete or error.
    • Create Shell script wrapper, which can be executed by External Scheduler.
  • You can create generic implementation of AMInvokeJob, that can take Application Module Definition and Operation Name as input, to invoke any Application Module's method.