You are on page 1of 7

Configure APEX in Oracle Database 11gR2

2 Comments Posted by oracleappsnotes on March 13, 2012


Oracle Application Express(APEX) comes pre-installed with the Oracle database from version 11g onwards.
Oracle 11gR2, comes with APEX version 3.2.1. However, before you actually start using the pre-installed
Oracle APEX, you need to configure it. The installation guide provides the complete details.
I configured APEX to run with the embedded PL/SQL gateway. The steps I followed for this are:
1. Configure the embedded PL/SQL gateway by running the configuration script apxconf.sql under
$ORACLE_HOME/apex. When prompted, enter a password for the APEX admin account and either provide a
port number for the XML DB HTTP server or choose the default(8080) one.
1
2
3 [oracle@db11gr2 apex]$ cd $ORACLE_HOME
4 [oracle@db11gr2 db_1]$ cd apex/
5 [oracle@db11gr2 apex]$ sqlplus /nolog
6 SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 11 00:48:32 2012
7
8 Copyright (c) 1982, 2009, Oracle. All rights reserved.
9
10SQL> connect sys as sysdba
11Enter password:
12Connected.
SQL>
13SQL>
14SQL>
15SQL> @apxconf
16
17PORT
18---------8080
19
20Enter values below for the XDB HTTP listener port and the password for the Application
21Express ADMIN user.
22Default values are in brackets [ ].
23Press Enter to accept the default value.
Enter a password for the ADMIN user []
24Enter a port for the XDB HTTP listener [ 8080]
25...changing HTTP Port
26
27PL/SQL procedure successfully completed.
28PL/SQL procedure successfully completed.
29Session altered.
30
...changing password for ADMIN
31
32PL/SQL procedure successfully completed.
33Commit complete.
34
35SQL>
36
37

2. Unlock the ANONYMOUS account


1SQL> ALTER USER ANONYMOUS ACCOUNT UNLOCK;
2
3User altered.
3. Verify whether the XML DB HTTP server is enabled by checking the port number
1SQL> SELECT DBMS_XDB.GETHTTPPORT FROM DUAL;
2
3GETHTTPPORT
4----------5 8080
6
7SQL>
In case the port number returns 0, enable the server by issuing the following commands in SQL Plus
EXEC DBMS_XDB.SETHTTPPORT(port_number);
COMMIT;
4. Enable network services for APEX. This is not a mandatory step but is required in case you want to access
network services from APEX. Please check the installation document for additional details. One of the results of
not implementing this step is that clicking on the Find link in the APEX help page will result in the following
error:

To allow access to network services, grant connect privileges to any host for the APEX_030200 database user.
This can be done by using the following script. Please check the installation guide on how to allow more fine
grained access.
1 DECLARE
2 ACL_PATH VARCHAR2(4000);
3 ACL_ID RAW(16);
BEGIN
4 -- Look for the ACL currently assigned to '*' and give APEX_030200
5 -- the "connect" privilege if APEX_030200 does not have the privilege yet.
6
7 SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
8 WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
9
checking the privilege, ensure that the ACL is valid
10----Before
(for example, does not contain stale references to dropped users).
11 -- If it does, the following exception will be raised:
12 -13 -- ORA-44416: Invalid ACL: Unresolved principal 'APEX_030200'
14 -- ORA-06512: at "XDB.DBMS_XDBZ", line ...
-15 SELECT SYS_OP_R2O(extractValue(P.RES, '/Resource/XMLRef')) INTO ACL_ID
16 FROM XDB.XDB$ACL A, PATH_VIEW P
17 WHERE extractValue(P.RES, '/Resource/XMLRef') = REF(A) AND
18 EQUALS_PATH(P.RES, ACL_PATH) = 1;
19

20DBMS_XDBZ.ValidateACL(ACL_ID);
21 IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, 'APEX_030200',
'connect') IS NULL THEN
22 DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
23 'APEX_030200', TRUE, 'connect');
24 END IF;
25
26EXCEPTION
When no ACL has been assigned to '*'.
27 -WHEN NO_DATA_FOUND THEN
28 DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml',
29 'ACL that lets power users to connect to everywhere',
30 'APEX_030200', TRUE, 'connect');
31 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*');
END;
32/
33COMMIT;
34
35
36
37
38
39
5. Enable indexing of online help. This step also is not mandatory, but not implementing this may result in the
following error while clicking the Find link in the APEX help pages

Enabling the indexing of online help, requires the permission to use an Oracle Text URL datastore to be granted
to the APEX_030200 database user. To implement this step, first find the database role which has been granted
this privilege. If no such role exists, then create a role, assign it to the APEX_030200 database user and grant
the required permission to the role. If the role exists, then just grant this role to the APEX_030200 user. In my
case, the role did not exist initially.
1 SQL> SELECT par_value FROM ctxsys.ctx_parameters WHERE par_name = 'FILE_ACCESS_ROLE';
2
PAR_VALUE
3 -------------------------------------------------------------------------------4
5 SQL> CREATE ROLE APEX_URL_DATASTORE_ROLE;
6
7 Role created.
8
9 SQL> GRANT APEX_URL_DATASTORE_ROLE to APEX_030200;
10
11Grant succeeded.
12
SQL> EXEC ctxsys.ctx_adm.set_parameter('file_access_role', 'APEX_URL_DATASTORE_ROLE');
13
14PL/SQL procedure successfully completed.
15
16SQL> commit;

17
18Commit complete.
19
20SQL>
21
22
6. The configuration steps are complete and all that remain are creating the workspace and users. Create an
APEX workspace by logging in as the administrator using the all URL, http://hostname:port/apex/apex_admin.
Here hostname will be the name of the system where the database is installed and port is the port number
specified in step#1. The username will be admin while the password is the one specified in step#1.

To create a new workspace, go to Manage Workspaces> Create Workspace. In Identify Workspace, enter a
workspace name and description and click Next.
In Identify Schema, enter the details as required. I opted for the following settings:
Re-use existing Schema? No
Schema Name: xxcustom
Schema Password: xxcustom
Space Quota: 10 MB
This will create a new schema named xxcustom and 10MB of space will be assigned to it.
In Identify Administrator, enter the details as required. I entered the following options:
Administrator Username:xxuser
Adminsitrator Password:xxuser
First Name:
Last Name:
Email:test@example.com
This will create the APEX user, xxuser since it does not exist. It will be created both as a developer and an
workspace administrator.
Confirm the selections and click on Create.
7. Additional users can be created by logging in as the administrator and navigating to Manage Workspace>
Manage Developers and Users> Create.
8. Once an user has been created, they can log in using the URL, http://hostname:port/apex

You might also like