Showing posts with label APEX. Show all posts
Showing posts with label APEX. Show all posts

Thursday, 1 September 2016

APEX Builder Installation error : ORA-00054: resource busy

While installing APEX builder in a duplicated database, I receive the following warnings and errors;

.  ____   ____           ____        ____
. /    \ |    \   /\    /     |     /
.|      ||    /  /  \  |      |    |
.|      ||---    ----  |      |    |-- 
.|      ||   \  /    \ |      |    |
. \____/ |    \/      \ \____ |____ \____
.
. Application Express Installation (DEV).
.........................................
.
... Checking prerequisites (ADD_DEV)
.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
.
... Prerequisite checks passed.
.
no rows selected
PL/SQL procedure successfully completed.
..................
..................
Installing SYS view wrappers
Create apex_sys_all_synonyms view

View created.

Create apex_sys_all_objects view

View created.

Create apex_sys_all_constraints view

View created.

Create apex_sys_all_dependencies view

View created.

Installing Team Development objects
...create team development objects
create table wwv_flow_news
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired 

create unique index wwv_flow_news_idx1 on wwv_flow_news(security_group_id, id)
                                         *
ERROR at line 1:
ORA-00942: table or view does not exist 

create table  wwv_flow_links (
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired 

create index wwv_flow_links_idx1 on wwv_flow_links (security_group_id)
                                    *
ERROR at line 1:
ORA-00942: table or view does not exist 

The installation continues, however, the side effects of the above missing objects are numerous.
Once the pages are loaded and the installer puts me back in the console, I notice a number of invalid objects in the apex schema.

It seems that during the Team Development object installation, a resource busy issue compromises the installation. The solution was not an entire re-installation but rather
a re-running of the problematic subset of the installer - manually - and chasing it up with a recompile.

The script that runs the Team development install is <APEX_SOURCE>\apex\devins.sql

Within the devins.sql script, I extract the following lines of script and rerun them manually as sysdba:

alter session set current_schema = APEX_040200;

prompt Installing Team Development objects
@./core/team_tab.sql
@./core/wwv_flow_team.sql
@./core/wwv_flow_team_api.sql
@./core/wwv_flow_team_gen_api.sql

I then run a recompile:
@?/rdbms/admin/utlrp

The APEX objects are valid again and the builder is accessible.


Monday, 20 June 2016

Upgrading Apex from 4.0.2 to 4.2 in Oracle XE


This post features the steps to upgrade Apex 4.0.2 to 4.2.2 in a Windows XE database.
The process of upgrading apex is pretty standard so this guide can apply a few versions of Apex.

OVERVIEW:
1. Create the APEX_DATA tablespace
2. Extract the APEX install files into a working directory
3. Shutdown the APEX gateway listener
4. Run the installation file
5. Check the registry and post installation status
6. Startup the APEX gateway listener

1. Create the APEX_DATA tablespace

CREATE TABLESPACE apex_data DATAFILE 'C:\ORACLE\APP\ORACLE\ORADATA\XE\APEX_DATA.DBF' SIZE 2G LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

2. Shutdown the APEX gateway listener
EXEC DBMS_XDB.sethttpport(0);

3. Extract the APEX install files into a working directory









I’ve moved the old $ORACLE_HOME/apex directory aside into $ORACLE_HOME/apex.4.0.2
I’ve extracted the 4.2.2 zip file into the $ORACLE_HOME/apex directory

4. Run the installation file

In cmd, change directory to your apex directory:
C:\oracle\app\oracle\product\11.2.0\server\apex

Log in to sqlplus as sysdba
sqlplus /nolog
conn / as sysdba

Check the current apex version in the database
SQL> select comp_name, version, status from dba_registry where comp_name = 'Oracle Application Express';

COMP_NAME                    VERSION          STATUS
---------------------------- ---------------- ------------------
Oracle Application Express   4.0.2            VALID

Run the apex installer
SQL> @apexins.sql APEX_DATA APEX_DATA TEMP /i/
.  ____   ____           ____        ____
. /    \ |    \   /\    /     |     /
.|      ||    /  /  \  |      |    |
.|      ||---    ----  |      |    |-- 
.|      ||   \  /    \ |      |    |
. \____/ |    \/      \ \____ |____ \____
.
. Application Express (APEX) Installation.
..........................................
.
... Checking prerequisites (MANUAL)
.

PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.

.
... Prerequisite checks passed.
.

Performing Application Express component validation - please wait...

old   6:     if '^UPGRADE' = '1' then
new   6:     if '2' = '1' then
old   7:        dbms_registry.loaded('APEX','^version');
new   7:        dbms_registry.loaded('APEX','4.2.2.00.11');
old   8:     elsif '^UPGRADE' = '2' then
new   8:     elsif '2' = '2' then
old  10:             dbms_registry.upgraded('APEX','^version');
new  10:             dbms_registry.upgraded('APEX','4.2.2.00.11');
old  12:             dbms_registry.loaded('APEX','^version');
new  12:             dbms_registry.loaded('APEX','4.2.2.00.11');
Completing registration process. 08:59:08
Validating installation.  08:59:08
...Database user "SYS", database schema "APEX_040200", user# "49" 08:59:08
...Compiled 0 out of 3004 objects considered, 0 failed compilation 08:59:09
...266 packages
...258 package bodies
...452 tables
...11 functions
...16 procedures
...3 sequences
...457 triggers
...1320 indexes
...211 views
...0 libraries
...6 types
...0 type bodies
...0 operators
...0 index types
...Begin key object existence check 08:59:09
...Completed key object existence check 08:59:09
...Setting DBMS Registry 08:59:09
...Setting DBMS Registry Complete 08:59:09
...Exiting validate 08:59:09

PL/SQL procedure successfully completed.

timing for: Validate Installation
Elapsed: 00:00:00.53
old   1: alter session set current_schema = ^APPUN
new   1: alter session set current_schema = APEX_040200

Session altered.

timing for: Complete Installation
Elapsed: 00:18:40.58

PL/SQL procedure successfully completed.


GLOBAL_NAME
------------------------------
SYS

1 row selected.

The apex installer will run for about 10-20 minutes while it reinstalls its libraries.

It will boot you out once it has completed.

5. Check the registry and post installation status
SQL> select comp_name, version, status from dba_registry where comp_name = 'Oracle Application Express';

COMP_NAME                      VERSION                        STATUS
------------------------------ ------------------------------ ---------------
Oracle Application Express     4.2.2.00.11                    VALID

SQL>

6. Startup the APEX gateway listener
EXEC DBMS_XDB.sethttpport(8080);

Done


Friday, 17 June 2016

Setting up a standalone APEX Listener in Glassfish

I setup Glass fish on a development box a few weeks ago. My understanding of how Glassfish works and where it fits into the enterprise architecture picture is limited but I believe I have an idea of what it is: Glassfish is a free application server. It looks and feels, at least to me, like a lightweight Oracle 11g Middleware. The reason why Glassfish was needed is that the development team wanted to setup an APEX listener and that listener needed to be accessible to the outside world and hosted outside of the database. The database that is at the centre of this setup has APEX 4.2 installed in it.

My notes for setting up APEX are below.

1. Download Glassfish and the APEX Standalone Listener:

Glassfish server can be found here:
https://glassfish.java.net/download.html

Listener can be found here:
http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/apex-listener-download-v205-2135981.html

*NOTE: The download locations can change from time to time, so for this post I used Apex Listener 2.0.5
I later learned that Oracle rebranded the listener to Oracle Restful Services. This note is focused on the old Apex Listener.

2. Install
Unzip Glassfish in a suitable location. I use E:\oracle\glassfish4. Glassfish works out the box so there is no installation required.

3. Start the default domain

E:\oracle\glassfish4\bin>asadmin start-domain
Waiting for domain1 to start ..................
Successfully started the domain : domain1
domain  Location: E:\oracle\glassfish4\glassfish\domains\domain1
Log File: E:\oracle\glassfish4\glassfish\domains\domain1\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.

4. Set the admin password 
For now, I use "adminadmin"

E:\oracle\glassfish4\bin>asadmin --host localhost --port 4848 change-admin-password
Enter admin user name [default: admin]>admin
Enter the admin password> <TYPE ADMINADMIN>
Enter the new admin password> <TYPE ADMINADMIN>
Enter the new admin password again> <TYPE ADMINADMIN>
Command change-admin-password executed successfully.

5. Enable secure admin
E:\oracle\glassfish4\bin>asadmin --host localhost --port 4848 enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin"> <TYPE ADMINADMIN>
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

6. Setup the APEX.WAR file for glassfish.
For Glassfish to present an Apex Listener, all it needs is the APEX.WAR file. I navigate to the location of the WAR file located inside the unzipped listener folder.
I then configure the file and save it. I configure the listener to use directory E:\oracle\glassfish4\glassfish\domains\domain1\apex_config to contain its configuration information.
So, make the directory E:\oracle\glassfish4\glassfish\domains\domain1\apex_config before configuring the WAR file.

G:\apex_listener_2_0_5>java -jar apex.war configdir E:\oracle\glassfish4\glassfish\domains\domain1\apex_config
Apr 21, 2016 3:30:10 PM oracle.dbtools.common.config.cmds.ConfigDir execute
INFO: Set config.dir to E:\oracle\glassfish4\glassfish\domains\domain1\apex_config in: G:\apex_listener_2_0_5\apex.war

7. Configure the listener to point to one database
G:\apex_listener_2_0_5>java -jar apex.war setup
Apr 21, 2016 3:30:43 PM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: E:\oracle\glassfish4\glassfish\domains\domain1\apex_config\apex
Enter the name of the database server [localhost]:<GLASSFISH SERVER>
Enter the database listen port [1521]:1522
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:2
Enter the database SID [xe]:<DATABASE SID>
Enter the database user name [APEX_PUBLIC_USER]:APEX_PUBLIC_USER
Enter the database password for APEX_PUBLIC_USER:
Confirm password:
Enter 1 to enter passwords for the RESTful Services database users (APEX_LISTENER,APEX_REST_PUBLIC_USER), 2 to use the same password as used for APEX_PUBLIC_USE
R or, 3 to skip this step [1]:1
Enter the database password for APEX_LISTENER:
Confirm password:
Enter the database password for APEX_REST_PUBLIC_USER:
Confirm password:
Apr 21, 2016 3:32:09 PM oracle.dbtools.common.config.file.ConfigurationFiles update
INFO: Updated configurations: defaults, apex, apex_al, apex_rt

8. Make the apex images directory available to the APEX.WAR file
These images are the ones found within the APEX database installation package.
On our development server, our /i alias is set to e:\apex422_images. So, I setup the war to point to the same location.

G:\apex_listener_2_0_5>java -jar apex.war static e:\apex422_images
WAR Generation complete
WAR location     : G:\apex_listener_2_0_5\i.war
Context path     : /i
Static resources : e:\apex422_images
Ensure the static resources are available at path: e:\apex422_images
on the server where the WAR is deployed

9. Upload the JAR file into glass fish.
Navigate to https://<GLASSFISH HOSTING SERVER>:4848





Enter the credentials selected earlier.
Once logged in, click the "Applications" link on the left. Once it opens in the right panel, click the "Deploy" button. You will presented with the screen below.




















Click the "Choose File" button and locate the WAR. Once selected, click "OK"

This will load the JAR file into the Glassfish framework.

9. Stop and start the domain
E:\oracle\glassfish4\bin>asadmin stop-domain
Waiting for the domain to stop .
Command stop-domain executed successfully.

E:\oracle\glassfish4\bin>asadmin start-domain
Waiting for domain1 to start ...........................................
Successfully started the domain : domain1
domain  Location: E:\oracle\glassfish4\glassfish\domains\domain1
Log File: E:\oracle\glassfish4\glassfish\domains\domain1\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.

10. Test glass fish and the new glasshfish administration page.

It seems that Glassfish piggy backs off port 8080 - the other webserver port when 80 is taken.
The glassfish administration console presents itself on port 4848.
To logon to the Glassfish administration console, use the credentials supplied in the APEX setup.

Test Apex

http://<GLASSFISH HOSTING SERVER>:8080/apex/apex_admin