Oracle XDB Restlet Adapter - FAQ

Where Restlet logging information goes?

Restlet framework and XMLDB Restlet Adapter uses JDK logging package, by default logging information goes to $ORACLE_BASE/diag/rdbms/$SID/$SID/trace directory.
Due REST WS are started by a background process automatically controlled by Oracle database logging information is at files named $SID_snnn_pid.trc, for example:

Trace file /u01/app/oracle/diag/rdbms/test/test/trace/test_s000_10024.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11_2_0_1_0/db_1
System name:    Linux
Node name:      mochoa
Release:        2.6.31.5-desktop-1mnb
Version:        #1 SMP Fri Oct 23 01:46:54 EDT 2009
Machine:        i686
Instance name: test
Redo thread mounted by this instance: 1
Oracle process number: 19
Unix process pid: 10024, image: oracle@mochoa (S000)

*** 2009-12-09 09:08:48.888
*** SESSION ID:(143.17) 2009-12-09 09:08:48.888
*** CLIENT ID:() 2009-12-09 09:08:48.888
*** SERVICE NAME:(SYS$USERS) 2009-12-09 09:08:48.888
*** MODULE NAME:() 2009-12-09 09:08:48.888
*** ACTION NAME:() 2009-12-09 09:08:48.888

jox_call_xdb_class_ c_state 0

*** 2008-06-04 15:28:23.018
jox_call_xdb_class_ argvec[0] 0 argvec[1] 0

*** 2009-12-09 09:17:42.296
jox_call_xdb_class_ argvec[0] 0 argvec[1] 0
UsersRestlet: init                         
UsersRestlet: [Noelios Restlet Engine] - The ServerServlet address = 127.0.0.1
UsersRestlet: [Noelios Restlet Engine] - The ServerServlet port = 8080        
UsersRestlet: [Noelios Restlet Engine] - The ServerServlet endpoint = 1       
UsersRestlet: [Noelios Restlet Engine] - Schema: RESTLET class: org.restlet.ext.xdb.XdbServerServlet loader: class oracle.aurora.rdbms.DbmsJava
Dec 9, 2009 12:17:42 PM org.restlet.ext.xdb.internal.XdbServletWarClientHelper start                                                           
INFO: efective user is: ANONYMOUS                                                                                                              
Dec 9, 2009 12:17:42 PM org.restlet.ext.xdb.internal.XdbServletWarClientHelper handleLocal                                                     
INFO: looking resources at: /home/ANONYMOUS/wars/UsersRestlet/WEB-INF/restlet.xml                                                              
Dec 9, 2009 12:17:42 PM org.restlet.ext.xdb.internal.XdbServletWarClientHelper start                                                           
INFO: efective user is: ANONYMOUS                                                                                                              
Dec 9, 2009 12:17:42 PM org.restlet.ext.xdb.internal.XdbServletWarClientHelper handleLocal                                                     
INFO: looking resources at: /home/ANONYMOUS/wars/UsersRestlet/WEB-INF/restlet.xml                                                              
UsersRestlet: [Noelios Restlet Engine] - Schema: RESTLET class: org.restlet.example.tutorial.Part12 loader: class oracle.aurora.rdbms.DbmsJava
Dec 9, 2009 12:17:42 PM org.restlet.ext.xdb.internal.XdbServletWarClientHelper start                                                           
INFO: efective user is: ANONYMOUS                                                                                                              
Dec 9, 2009 12:17:42 PM org.restlet.ext.xdb.internal.XdbServletWarClientHelper handleLocal                                                     
INFO: looking resources at: /home/ANONYMOUS/wars/UsersRestlet/WEB-INF/restlet.xml                                                              
UsersRestlet: [Restlet] Attaching application: org.restlet.example.tutorial.Part12@e2c7e499 to URI: /userapp                                   
Dec 9, 2009 12:17:42 PM org.restlet.ext.xdb.internal.XdbServletWarClientHelper start                                                           
INFO: efective user is: ANONYMOUS                                                                                                              

*** 2009-12-09 09:17:43.598
Dec 9, 2009 12:17:43 PM org.restlet.engine.log.LogFilter afterHandle
INFO: 2009-12-09        12:17:43        -       -       127.0.0.1       8080    GET     /userapp/users/scott/orders/300 -       200     28      -       1001    http://localhost:8080   -       -

How many concurrent session are started by Oracle?

As mentioned in previous answer the Oracle JVM session which receives the request is automatically started by Oracle, how many concurrent sessions are started by Oracle Listener is automatically computed by Oracle and you don't care about it. My testing shows that for heavy workload there is around 5 to 7 % of concurrent request.

Which is the effective Oracle user when run a REST WS?

It depends on the HTTP authorization mechanism.
REST WS which are available as anonymous access, no HTTP authorization information, runs with ANONYMOUS Oracle user and PUBLIC database role.
REST WS which are authorized though HTTP header Authorization are executed with his effective Oracle user, for example SCOTT.

How to enable anonymous REST WS?

First unlock ANONYMOUS Oracle account. By default XMLDB Restlet Adapter do this command at postInstall.sql script

SQL> alter user anonymous account unlock;

Then you have to register your Restlet application into XMLDB configuration file (named /xdbconfig.xml) with this Servlet role:

              <servlet xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd">
                <servlet-name>UsersRestlet</servlet-name>
                <servlet-language>Java</servlet-language>
                <display-name>Restlet Servlet</display-name>
                <servlet-class>org.restlet.ext.xdb.XdbServerServlet</servlet-class>
                <servlet-schema>PUBLIC</servlet-schema>
                <init-param xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd">
                  <param-name>org.restlet.application</param-name>
                  <param-value>RESTLET:org.restlet.example.tutorial.Part12</param-value>
                  <description>REST User Application</description>
                </init-param>
                <security-role-ref xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd">
                  <description/>
                  <role-name>PUBLIC</role-name>
                  <role-link>PUBLIC</role-link>
                </security-role-ref>
              </servlet>

Above registration can be done by a following PLSQL script executed logged as SYS:

DECLARE
  configxml SYS.XMLType;
begin
  dbms_xdb.deleteServletMapping('UsersRestlet');
  dbms_xdb.deleteServlet('UsersRestlet');
  dbms_xdb.addServlet(name=>'UsersRestlet',language=>'Java',class=>'org.restlet.ext.xdb.XdbServerServlet',dispname=>'Restlet Servlet',schema=>'PUBLIC');
  -- Modify the configuration
  -- Due this servlet provide public access, it can not load
  -- '/home/'||USER||'/restlet/UsersRestlet.xml' from XMLDB repository
  SELECT INSERTCHILDXML(xdburitype('/xdbconfig.xml').getXML(),'/xdbconfig/sysconfig/protocolconfig/httpconfig/webappconfig/servletconfig/servlet-list/servlet[servlet-name="UsersRestlet"]','init-param',
  XMLType('<init-param xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd">
                  <param-name>org.restlet.application</param-name>
                  <param-value>RESTLET:org.restlet.example.tutorial.Part12</param-value>
                  <description>REST User Application</description>
           </init-param>'),'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"') INTO configxml
  FROM DUAL;
  -- Update the configuration to use the modified version
  --I got this error at this line :
  dbms_xdb.cfg_update(configxml);
  dbms_xdb.addServletSecRole(SERVNAME => 'UsersRestlet',ROLENAME => 'PUBLIC',ROLELINK => 'PUBLIC');
  dbms_xdb.addServletMapping('/userapp/*','UsersRestlet');
  commit;
end;
/
commit;

For more information on how to register a Servlet with anonymous access read Using Protocols to Access the Repository.

How can I define my Application in XdbServerServlet?

XMLDB do not accept context parameters so unlike org.restlet.ext.servlet.ServerServlet class, XdbServerServlet have two way to define org.restlet.application parameter.
First option was used in previous examples, it means using Servlet 2.2 <init-param> tag, this is very useful for anonymous REST applications.
For authenticated applications there is another option which is to put an XML file at XMLDB repository using this predefined path:
/home/USER/wars/appName/WEB-INF/restlet.xml

where USER is the efective connected username, for example SCOTT, and appName is the servlet name; name argument in dbms_xdb.addServlet procedure used for registering Servlet in XMLDB, in above example is UsersRestlet.

This file look like:

<restlet-app>
   <org.restlet.application>org.restlet.example.tutorial.Part12</org.restlet.application>
</restlet-app>

Second option do not require DBA role if you want to update your application class name.

Return to main document.

Comments (0)