Using APEX Listener as Stand-alone HTTP server on Windows

Oracle provides a good alternative for using the EPG in single-developer projects. It is called the Oracle APEX Listener.

it is intended to run as some kind of plug-in in:

  • Oracle WebLogic Server.
  • Oracle GlassFish Server.
  • Oracle Containers for J2EE (OC4J).

But it also runs in a stand alone mode.

This time I’d like to discuss the latter, stand-alone mode.

Advantages

Using the listener in stand-alone mode, for me, has several advantages.

  • super fast to set up
  • easy to automate
  • possibility to start more instances (ie for each APEX instance)
  • no WebDav/FTP access required to the /i/ folder
    (this also has a drawback when enrolling your app)

Disadvantages

The main drawback is that it won’t install as a service on Windows.

Setup

Using the installation guide you’ll be up and running within minutes. Oracle did a good job in explaining this. I will not elaborate further on this.

In essence you need to start the Listener as follows:

java.exe -Dapex.home={PATH_A} -Dapex.images={PATH_B} -Dapex.port={PORTNUMBER} -jar {PATH_C}

The Listener now will try to find settings in the {PATH_A}. If it cannot find them, it will first ask for a username and password for the adminlistener and managerlistener users, after which it will start the browser with a configuration page.

Apex listener configuration page
Apex listener configuration page

Here you give the Listener the information it needs to connect to the database. It’s a kind of DAD… You only have to fill out the first tab. The rest you can leave as default. When you apply the Listener will save this information into the {PATH_A} location.

{PATH_B} points to the images directory, in my case that is d:\apex4\apex\images\ so I can edit and save CSS, images, HTML etc as I please.

{PORTNUMBER} is the portnumber the listener is listening to. In my case that is 81, but you can put it on any port you like (even 80!).

{PATH_C} points to the apex.war java program.

Once the Listener has saved the connect-information into the {PATH_A} location, we can easily switch the listener to another port without any re-configuration. Just use the same command and only replace the {PORTNUMBER} variable with the desired port-number. My batch-file will handle this.

Putting it all together

Now I’ve explained how to start the listener the next step is to do some automation.

I created a batch file that you can use to automate starting the Listener.

::@echo off

pushd D:\Oracle\apxlistener\
setlocal

set tmp=tmp.%1%
set java=c:\Program Files\Java\jdk1.6.0_24\bin\java.exe
set apx_user = RMARTENS
set apx_workspace = APEXDEMO
set apx_listener = D:\Oracle\apxlistener\apex.war
set browser = "c:\Program Files (x86)\Mozilla Firefox\firefox.exe"

if not exist %tmp% mkdir %tmp%

start "ApexListener %2% %1%" /MIN "%java%" "-Dapex.home=%tmp%" -Dapex.images=D:\apex4\apex\images\ -Dapex.port=%2% -jar %apx_listener%

pause

echo Listener started

start "Oracle Apex" %browser% "http://localhost:%2%/apex/f?p=4550:1:::::F4550_P1_COMPANY,F4550_P1_USERNAME:%apx_workspace%,%apx_user%"

:einde
endlocal
popd
exit

If you save this as a batch file and edit lines 7 to 11 to reflect your settings, you’ll be able to start your listener as:

apxlistener.bat apexdemo 81

Which starts the listener using the settings in the apexdemo folder on port 81.

The batch can be further extended to have different /i/ folders for each environment, but for me that was not needed.

— Good Luck ! —

2 thoughts on “Using APEX Listener as Stand-alone HTTP server on Windows”

Leave a Comment