Exporting Apex application from Backend – Apex 4.1

Recently I ended up screwing up my Apex application. I was trying to enable SSL (making URL https) for security reason and somehow the configuration did not work on production.

At this stage I was trying to get back my APEX application. Unfortunately nothing seems to be working.

So I thought of doing a complete reinstall of APEX but I didn’t have backup of my application.

Nice thing, I found how to export your APEX application from backend. You don’t have to login to GUI (to your workspace) to export your application. Here are the simple steps to export the applications

Step 1) Make sure you have apex home

Many time we download APEX, install in our database and later delete the files of APEX as they are not required.

If you have delete the files, make sure you download same version again. APEX home is required for exporting application

Step 2) Check APEXExport.class is present in utilities/oracle/apex directory

Check out following 3 files should be present under APEX_HOME

*** I am referring APEX_HOME to the directory where apex is extracted.

1) readme.txt – Should be present in $APEX_HOME/utilities/readme.txt

Check out this file. This will give you idea about how to do the export. Don’t jump in running export command

2) APEXExport.class – Should be present in $APEX_HOME/utilities/oracle/apex/APEXExport.class

This java class file is responsible for doing the export. This will generate f<appl No>.sql file.

3) APEXExportSplitter.class – Should be present in $APEX_HOME/utilities/oracle/apex/APEXExportSplitter.class

This can be used used to split Oracle Application Express export files into separate SQL scripts. This is useful for management of files corresponding to the discrete elements of an Application Express application.

Step 3) Getting correct version and setting correct environment variable

Its very important that we have correct version of JAVA present in our environment and also we should make sure that we set environment variables correctly.

If any of these are not correct (java version or environment variables), export will not work.

You need to download and install JDK1.6 as this will not working on lower version of JDK (to my experience).

You can download the same from http://www.oracle.com/technetwork/java/javase/downloads/index.html

After downloading and installing JDK 1.6, you need to set following environment

  1. CLASSPATH
  2. JAVA_HOME
  3. PATH

If you set any of environment variable incorrectly, export won’t work.

I tried following CLASSPATH, but got error

export CLASSPATH=.:${ORACLE_HOME}/jdbc/lib/ojdbc5.jar
java oracle/apex/APEXExport -db apex-server.db.example.com:1525:apexdb -user <apex_schema> -password <passwd> -applicationid 101
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
 at oracle.apex.APEXExport.main(APEXExport.java:825)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
 at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
 ... 1 more

I tried few more combination of CLASSPATH variable, but nothing worked. Finally I set following variables and after that export worked.

In my case apex was extracted on $HOME/product/apex location.

Following setting worked:-

export CLASSPATH=.:${ORACLE_HOME}/oui/jlib/classes12.jar
export JAVA_HOME=/opt/app/oracle/product/jdk1.6.0_38/jre
export PATH=/opt/app/oracle/product/jdk1.6.0_38/bin:$PATH
cd $HOME/product/apex/utilities
java oracle/apex/APEXExport -db apex-server.db.example.com:1525:apexdb -user <apex_schema> -password <passwd> -applicationid 101

Exporting application 101
Completed at Mon May 06 15:44:53 UTC 2013

Hope this helps !!

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s