Friday, February 13, 2009

APEX V3.1.2 Runtime Adminitration

Currently working on a third party developed application, that does user management from within the application. Nothing special, you'd say.
Nope, it is not. But for the part, where a new user needs to get privileges to add other users... The query used to check whether a user can administer application users is a join over the view FLOWS_030100.APEX_WORKSPACE_APEX_USERS, specifically the column IS_ADMIN. Now, promoting an APEX application user to administrator is simple in the developer environment. In a runtime only environment, it is a little bit harder.

In fact, I can install new versions of the application by logging on to the database with SQL*Plus as workspace owner, and run the script. One of the first things this script does is:

begin wwv_flow_api.set_security_group_id(
p_security_group_id => APEX_UTIL.FIND_SECURITY_GROUP_ID('NAME'));
end;
/

After that, it continues with the creation of the flow (after the flow was dropped):

wwv_flow_api.create_flow(
p_id => 100,
p_display_id=> 100,
p_owner => 'OWNER',
p_name => 'NAME',

... etc...

However, owner corresponds with an Oracle database account, and there's a policy to have different application accounts from the database accounts. So in the workspace import (wwv_flow_fnd_user_api.create_company), there's a difference between Workspace schema (p_company_schemas) and provisioning schema (p_first_schema_provisioned) on one side, and the Workspace Administrator (wwv_flow_fnd_user_api.create_fnd_user) on the other.

As stated: I can log on to the database as owner (Oracle account) and install the application. However, what I cannot do is:

begin wwv_flow_api.set_security_group_id(
p_security_group_id => APEX_UTIL.FIND_SECURITY_GROUP_ID('NAME'));
end;
/
begin
apex_util.edit_user(
p_user_id => apex_util.get_user_id('APP_ADMIN'),
p_user_name => 'APP_ADMIN',
p_developer_privs => 'ADMIN:');
end;
/

It simply results in:

ERROR at line 1:
ORA-20001: User requires ADMIN privilege to perform this operation.
ORA-06512: at "FLOWS_030100.WWV_FLOW_FND_USER_API", line 76
ORA-06512: at "FLOWS_030100.WWV_FLOW_FND_USER_API", line 1192
ORA-06512: at "FLOWS_030100.HTMLDB_UTIL", line 756
ORA-06512: at line 2

The workaround is to execute this code as SYS (SYSTEM should work, too).

I suspect is is to do with the fact, the Workspace Administrator name differs from the owner of the application. Or, in technical terms, FLOWS_030100.APEX_WORKSPACE_APEX_USERS.USER_NAME does not correspond with the pseudo column USER.

Thursday, January 15, 2009

Top-25

A little late, this top-25, but noteworthy, non the less. The top-25 of programming errors. What about Improper Encoding or Escaping of Output, or SQL Injection (the CWE organization calls it 'Failure to Preserve SQL Query Structure')

Others, I like:
Improper Initialization
Client-Side Enforcement of Server-Side Security
Hard-Coded Password
and, one I blogged about years ago: Use of a Broken or Risky Cryptographic Algorithm

Must read: the SQL Injection cheat sheet

Sunday, September 07, 2008

10G database on Ubuntu 8.04 (Hardy Heron)

I will describe what I did to get 10G Rel2 working on Ubuntu 8.04, codename Hardy Heron. Lot of the research was already done, of course, and comes from here.

Update and upgrade.
I made sure I got the latest version by switching to root, and upgrading/updating:

frank@IA-laptop:~$ sudo su -
[sudo] password for frank:
root@IA-laptop:~# apt-get update
Hit http://nl.archive.ubuntu.com hardy Release.gpg
Ign http://nl.archive.ubuntu.com hardy/main Translation-en_US
Get:1 http://security.ubuntu.com hardy-security Release.gpg [189B]
Ign http://security.ubuntu.com hardy-security/main Translation-en_US
[...]
[...snipped output...]
[...]
Get:14 http://nl.archive.ubuntu.com hardy-updates/restricted Packages [6636B]
Get:15 http://nl.archive.ubuntu.com hardy-updates/main Sources [87.9kB]
Get:16 http://nl.archive.ubuntu.com hardy-updates/restricted Sources [908B]
Get:17 http://nl.archive.ubuntu.com hardy-updates/universe Packages [90.6kB]
Get:18 http://nl.archive.ubuntu.com hardy-updates/universe Sources [22.7kB]
Get:19 http://nl.archive.ubuntu.com hardy-updates/multiverse Packages [20.1kB]
Get:20 http://nl.archive.ubuntu.com hardy-updates/multiverse Sources [2795B]
Fetched 776kB in 1s (467kB/s)
Reading package lists... Done
root@IA-laptop:~# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
language-pack-en language-pack-gnome-en libsmbclient libxml2 libxml2-utils
python-libxml2 samba-common smbclient
8 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.0MB of archives.
After this operation, 500kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://nl.archive.ubuntu.com hardy-updates/main language-pack-en 1:8.04+20080805 [236kB]
Get:2 http://security.ubuntu.com hardy-security/main libxml2 2.6.31.dfsg-2ubuntu1.1 [785kB]
Get:3 http://nl.archive.ubuntu.com hardy-updates/main language-pack-gnome-en 1:8.04+20080805 [96.7kB]
Get:4 http://nl.archive.ubuntu.com hardy-updates/main smbclient 3.0.28a-1ubuntu4.5 [4863kB]
Get:5 http://security.ubuntu.com hardy-security/main libxml2-utils 2.6.31.dfsg-2ubuntu1.1 [34.0kB]
Get:6 http://security.ubuntu.com hardy-security/main python-libxml2 2.6.31.dfsg-2ubuntu1.1 [263kB]
Get:7 http://nl.archive.ubuntu.com hardy-updates/main samba-common 3.0.28a-1ubuntu4.5 [2840kB]
Get:8 http://nl.archive.ubuntu.com hardy-updates/main libsmbclient 3.0.28a-1ubuntu4.5 [887kB]
Fetched 10.0MB in 19s (523kB/s)
Preconfiguring packages ...
(Reading database ... 138248 files and directories currently installed.)
Preparing to replace language-pack-en 1:8.04+20080708 (using .../language-
[...]
[...snipped output...]
[...]
Setting up samba-common (3.0.28a-1ubuntu4.5) ...

Setting up smbclient (3.0.28a-1ubuntu4.5) ...
Setting up libsmbclient (3.0.28a-1ubuntu4.5) ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place
root@IA-laptop:~#


Then I continued by getting these packages:

apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm libstdc++5

After that, I created the oinstall and dba groups and the oracle account, much like in step 7, and as done in previous installs:

groupadd oinstall
groupadd dba
groupadd nobody
useradd -g oinstall -G dba -d /home/oracle -s /bin/bash oracle
passwd oracle

I changed the limits and system-wide settings, and reloaded these using sysctl -p (well, actually, I rebooted into a new kernel)
In the mean time, downloading the database and companion disks has completed; time to get serious:

root@IA-laptop:~# mkdir -p /oracle/prd/db/10.1.2
root@IA-laptop:~# chown -R oracle:oinstall /oracle
root@IA-laptop:~# echo 4 >> /etc/redhat-release
root@IA-laptop:~# ln -s /usr/bin/rpm /bin/rpm
root@IA-laptop:~# ln -s /usr/bin/basename /bin/basename
root@IA-laptop:~# ln -s /usr/bin/rpm /bin/rpm
root@IA-laptop:~# ln -s /usr/bin/awk /bin/awk
root@IA-laptop:~# su - oracle
oracle@IA-laptop:~$ mkdir /oracle/install
oracle@IA-laptop:~$ cd /oracle/install
oracle@IA-laptop:~$ unzip /home/frank/10201_database_linux32.zip
oracle@IA-laptop:~$ cd /oracle/install/database/install
oracle@IA-laptop:~$ export DISPLAY=:0
oracle@IA-laptop:~$ ./runInstaller

Run /oracle/prd/oraInventory/orainstRoot.sh and /oracle/prd/db/10.1.2/root.sh and about 10 minutes later, I was done (admit, I needed to rerun root.sh, after adding the group nobody).
Final thing to do, is to alter the login scrpt for the oracle user:

oracle@IA-laptop:~$ cd
oracle@IA-laptop:~$ vi .profile
export ORACLE_BASE=/oracle/prd
export ORACLE_HOME=$ORACLE_BASE/db/10.1.2
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl
export DISPLAY=:0.0
echo "Oracle settings done"


The instance
Time to create an instance... which will have to be discarded, as I forgot to install the companion disk...
Enough for now; the formula 1 circus has landed in Spa.

Monday, September 01, 2008

Oracle on Ubuntu

The company I work for has supplied me with a very decent laptop, in December 2007, equipped with an Intel Core Duo T7500 processor, 4GB of RAM, and an 160GB Harddisk. The only downside (and reason I hardly ever use the thing) is Vista Enterpise. Apart from the fact Oracle only recently certified versions for Vista, it takes forever to get it into a state I can actually do some work. I timed it once, and it took 5 minutes for Vista to get into a working state (showing off a picture is not what I regard "working state"), including getting an IP-address from my local NAS, setting up an VPN session to the internal network and firing up my email application.
As a comparison, Ubuntu does the same (without the VPN), in about a minute.

Why all this?
Well, it basically explains why I installed Ubuntu next to Vista (dual boot configuration); I really got fed up with the abysmal performance of Vista. And no, it will probably not be all Vista's fault (our IT department uses images with a lot of stuff starting up), but an OS reporting 3GB where there's really 4GB installed - well, that's 33% gain by installing an OS that actually uses that last GB!

CentOS
Installing Ubuntu (Desktop) was easy; CentOS, the platform of choice for me as Oracle gets onto Linux, failed miserably in recognizing the graphics driver - even the text based install got stuck.
Did not spent much time on the issue, don't think much of it. It's a laptop, not server hardware!

RDBMS: 10G Rel2
I think 11G can be installed on Ubuntu without too much of an effort, but this side of the ocean, not many clients have 11G, or plans for that matter. So, for now, I'll stick to 10G Rel 2 - Enterprise, of course...

iAS: 10G Rel 3, patch 4
Or Version 10.1.3.4, for that matter. The SOA Suite Edition - get that running, and you can get anything to run.

Sunday, August 17, 2008

Error creating new OC4J instance: Invalid protocol or port range.

This is an attempt to install the SOA Suite, using Oracle AS 10.1.3.4 on HP-UX using the Enterprise Deployment Guide; the complete error message is:

Error creating new OC4J instance: create oc4j instance fails: Invalid protocol or port range. There is no OHS installed on the Oracle Home. So new OC4J instance can not use ajp protocol. Please use the -protocol and -httpPort option on the command to create OC4J.

As an alternative, I tried from the command prompt, running the createinstance command from $ORACLE_HOME/bin. To no relief.
Of course, google came up empty, as did metalink; however, I found a workaround that seems to work (This is install is not quite ready, yet):

cd $ORACLE_HOME/bin
./createinstance -instanceName oc4j_soa -groupName soa_group -httpPort 8435 -protocol http
./createinstance -instanceName oc4j_esbdt -groupName esbdt_group -httpPort 8435 -protocol http
Then, edit opmn.xml (in $ORACLE_HOME/opmn/conf/) and change

<port id="default-web-site" range="8435" protocol="http"/>
into:
<port id="default-web-site" range="12501-12600" protocol="ajp"/>

Do this for both instances just created (oc4j_soa and oc4j_esbdt).
And just as a side note: create these in lower case, as there's a patch (PERL script, actually), that checks for a lower case oc4j_soa!

Next, opmnctl reload and start, and we're in business. The EDG (linked in the title) states that an AJP port should be picked, but defining a range makes the Application Server choosing the next free port.

Friday, August 08, 2008

Cannot deploy because already deployed?

Oracle Application Server playing bezerk? You undeployed an application, but ran into a memory error (or another).

An error occured while undeploying the application. The evaluate phase failed. The Adapter used in the evaluate may have thrown an exception.
Resolution:
Please call Oracle support.
Base Exception:
java.lang.OutOfMemoryError
null. java.lang.OutOfMemoryError

No trace of your application, but a deployment fails with:

Deployment failed
Base Exception: J2EE application: [application_name] has already been deployed. Redeploy needs to be used to override previous deployed application.


The solution is to check whether or not all traces have indeed been removed (obviously not):

$ORACLE_HOME/dcm/bin/dcmctl listapplications -co [container]

will still show your application. If it does, remove it with the following command:

$ORACLE_HOME/dcm/bin/dcmctl undeployapplication -a [appl] -co [container] -force -d -v

You should now be able to deploy again.

The Reverse
You see your application in Enterprise Manager Console, but cannot undeploy, due to a failed deployment. Reverse situation from above:

- check $ORACLE_HOME/j2ee/[container_name]/application-deployments
- check $ORACLE_HOME/j2ee/[container_name]/applications
for directories and ear files named after your application.
- check $ORACLE_HOME/j2ee/[container_name]/config/server.xml for entries regarding your application, and remove this line.
- check $ORACLE_HOME/j2ee/[container_name]/config/default-web-site.xml for entries regarding your application, and remove this line.

Perform an opmnctl reload, and restart OEM (emctl stop iasconsole); you should now be able to deploy again.

Friday, February 08, 2008

SOA 10.1.3.3 install fails on multi IP machine...

Of course, it's the 10.1.3.1 install, before patching to 10.1.3.3.
You need to define VIRTUAL_HOST_NAME (yes - that is virtual-underscore-host-underscore-name).
In addition to OUI_HOSTNAME, ORACLE_HOSTNAME and EMHOSTNAME, that is...

So, if confronted with errors during the configuration stage (ESB goes wrong according to log, but gets status succeeded, BPEL Process Manager fails with Failed at "Could not get DeploymentManager", define VIRTUAL_HOST_NAME, and retry the installation.