Category Archives: APEX

Configure RestFull Services on Apex Listener

I had to configure Apex Listener to work with RestFull Services. After a lot of hours of debugging I managed to make my Apex Listener on Weblogic to respond to the services.

A think that helped me a lot in all this debugging was the Apex Standalone server (if your environement is not in production or dev you can modify that as well) started in the debug mode. Basically you have to change the defaults.xml file in the Apex Listnere configdir and enable the on screen display:

<entry key="debug.printDebugToScreen">true</entry>

The steps to make it all work are the following:

1. Change directory to your apex installation and connect to the database and run apex_rest_config.sql and set the password for the APEX_LISTENER and APEX_REST_PUBLIC_USER users.
Note: If you do this step after step 2, be sure to unlock the two users because they will get locked when Apex Listener will try to connect with the wrong password.

2. Deploy Apex to Weblogic according to the official documentation here: http://docs.oracle.com/cd/E37099_01/doc/doc.20/e25066/install.htm#autoId17
Note: Be sure to enter the correct users and passwords.

3. In our case, there were a lot of Workspaces created before installing and enabling RestFull Services. I think that for all the Workspaces that are created before enabling RestFull Services or created on the same Apex Instance but from another deployment that does not have RestFull Services (like Apache) the url-mappings are not correct. If you try to test the service on a old Workspace you will get the following error:

Request Path passes syntax validation
Mapping request to database pool: PoolMap [_poolName=apex, _regex=null, _workspaceIdentifier=null, _failed=false, _lastUpdate=-1, _template=null, _type=REGEX]
Applied database connection info
Attempting to process with PL/SQL Gateway
Not processed as PL/SQL Gateway request
Attempting to process as a RESTful Service
Determining if request can be dispatched as a Tenanted RESTful Service
Request path has one path segment, continuing processing
No Tenant Principal established yet, continuing processing
APEX_LISTENER pool exists, continuing processing
No matching tenant found for: travel, cannot dispatch
No candidate found for: GET travel/hr/empinfo/ in context: http://localhost:8080/apex/

In the above example travel is the Workspace.

For the restfull services to work on old workspaces you will have to create the mappings manually according to the documetnation: http://docs.oracle.com/cd/E37099_01/doc/doc.20/e25066/config.htm#autoId3. In our example you should run:

java -jar apex.war map-url --type base-path --workspace-id travel /travel apex

And that should fix the issue.

PlsqlDatabaseConnectString takes 1-2 arguments, Connect String to Database (SID, Service Name, TNS)

If you see the error bellow it means that you haven’t configured the mod_plsql PlsqlDatabaseConnectString parameter correctly in dads.conf. There are multiple ways to configure it:

1. Connection string:

PlsqlDatabaseConnectString server_hostname:1521:DB_SID

2. TNSName entry with tnsnames.ora

PlsqlDatabaseConnectString TNS_ENTRY

For this to work you also need to have a tnsnames.ora file in OHS_HOME/network/admin/tnsnames.ora (in my case /u01/app/oracle/product/FMW/Oracle_WT/network/admin/tnsnames.ora) with the corresponding tns entry.

3. TNSNameFormat (Notice there are no spaces)

PlsqlDatabaseConnectString     (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=DB_SERVICE_NAME)))

With this you can put multiple servers, create load balance, etc. as you would do with a tns entry in tnsnames.ora file.