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:

-bash-3.2$ more test_s000_10388.trc
Trace file /u01/app/oracle/diag/rdbms/test/test/trace/test_s000_10388.trc
Oracle Database 11g Release 11.1.0.6.0 - Production
ORACLE_HOME = /u01/app/oracle/product/11.1.0.6.0/db_1
System name:    Linux
Node name:      mochoa.exa.unicen.edu.ar
Release:        2.6.22.19-laptop-2mdv
Version:        #1 SMP Mon May 5 21:03:49 EDT 2008
Machine:        i686
Instance name: test
Redo thread mounted by this instance: 1
Oracle process number: 17
Unix process pid: 10388, image: oracle@mochoa.exa.unicen.edu.ar (S000)

*** 2008-06-04 15:28:23.018
*** SESSION ID:(140.49) 2008-06-04 15:28:23.018
*** CLIENT ID:() 2008-06-04 15:28:23.018
*** SERVICE NAME:(SYS$USERS) 2008-06-04 15:28:23.018
*** MODULE NAME:() 2008-06-04 15:28:23.018
*** ACTION NAME:() 2008-06-04 15:28:23.018

jox_call_xdb_class_ c_state 0

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

*** 2008-06-04 15:28:23.715
UsersRestlet: init
UsersRestlet: [Noelios Restlet Engine] - The ServerServlet address = null
UsersRestlet: [Noelios Restlet Engine] - The ServerServlet port = 8080
UsersRestlet: [Noelios Restlet Engine] - The ServerServlet endpoint = 1
UsersRestlet: [Noelios Restlet Engine] - Try to load 'org.restlet.attribute.application' parameter from '/home/'||USER||'/restlet/UsersRestlet
.xml

*** 2008-06-04 15:28:25.580
UsersRestlet: [Noelios Restlet Engine] - Try to load 'org.restlet.attribute.component' parameter from '/home/'||USER||'/restlet/UsersRestlet.x
ml
UsersRestlet: [Noelios Restlet Engine] - Try to load 'org.restlet.component' parameter from '/home/'||USER||'/restlet/UsersRestlet.xml

*** 2008-06-04 15:28:27.089
Jun 4, 2008 6:28:26 PM org.restlet.Connector <init>
WARNING: The connector has been instantiated without any protocol.
UsersRestlet: [Noelios Restlet Engine] - Try to load 'org.restlet.application' parameter from '/home/'||USER||'/restlet/UsersRestlet.xml
UsersRestlet: [Noelios Restlet Engine] - Schema: RESTLET class: RESTLET:org.restlet.example.tutorial.Part12 loader: class oracle.aurora.rdbms.
DbmsJava
UsersRestlet: [Noelios Restlet Engine] - Try to load 'org.restlet.attribute.server' parameter from '/home/'||USER||'/restlet/UsersRestlet.xml
UsersRestlet: [Noelios Restlet Engine] - Attaching application: org.restlet.example.tutorial.Part12@8b9e5a01 to URI: /userapp
Jun 4, 2008 6:28:27 PM com.noelios.restlet.http.HttpServerCall parseHost
INFO: Couldn't find the mandatory "Host" HTTP header.
Jun 4, 2008 6:28:27 PM com.noelios.restlet.ext.xdb.XdbServletWarClientHelper start
INFO: efective user is: ANONYMOUS

*** 2008-06-04 15:28:27.588
Jun 4, 2008 6:28:27 PM com.noelios.restlet.LogFilter afterHandle
INFO: 2008-06-04        18:28:27        -       -       -       8080    GET     /userapp/users/scott/orders/300 -       200     28      -    155      http://null     -       -

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>com.noelios.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=>'com.noelios.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 com.noelios.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/restlet/appName.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)
Navigation doc: view