Why do we need a local instance of OPA Hub?
Whilst Oracle Policy Modeling 12 contains a valuable Debug tool, there are many projects that need to be demonstrated in the Hub environment, either because they require integration with external components, or for the purposes of demonstration and testing in a live environment. This can only be done by deploying to an instance of the OPA Hub. However a remote OPA Hub may not always be available due to lack of Internet access, restrictions of space or other factors beyond the developerâ€™s control. This tutorial will demonstrate how to set up an OPA Hub locally on a Windows PC, whose behavior will be identical to a remote OPA Hub.
Step 1: Install Oracle XE database
Download Oracle XE 11g database from here:
The installation guide can be found here:
Follow the instructions for â€œPerforming a Graphical User Interface Installation of the Serverâ€
Create a user and password for the database as detailed here:
Important: note down the user name and password chosen.
Step 2: Install Tomcat
Download Tomcat from here:
Click on the link to the zip version of Core binary distribution appropriate for your Windows version, e.g. 64-bit Windows zip. Save the file somewhere (e.g. Downloads).
Navigate to the downloaded file, double-click on it to open the zip, and extract it to a directory using your preferred zip tool (WinRAR is shown in the figure). The directory should not be a protected Windows directory. It is important that there are no spaces in any of the directories in the path. E.g.
C:\Users\Alastair Calderwood\apache-tomcat-8.0.26 is not a valid path
C:\Users\Alastair\apache-tomcat-8.0.26 is a valid path
You will now need to add a file containing the Oracle database driver to Tomcat. This is already contained in the Oracle XE database installed previously, and simply needs to be copied.
Navigate to the directory C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib
Right-click on the file ojdbc6.jar and select Copy (or CTRL+C).
Navigate to the directory where you installed (unzipped) Tomcat and select lib. Now paste the file by right-clicking on an empty area of the window, and selecting Paste (or CTRL+V).
Step 3: Install Oracle Policy Modeling
You may already have a version of Oracle Policy Modeling 12 installed. If so, note down the version by opening Oracle Policy Modeling:
If you do not have OPM installed, download from here:
If you have it installed, you may wish to check that it is the latest version, and update as necessary.
Step 4: Build Oracle Policy Automation Server Components (Hub)
You need to download the version of Oracle Policy Automation server components corresponding to Oracle Policy Modeling noted above, since differing versions will not be compatible. This can be downloaded here:
Navigate to the downloaded file (e.g. OPA_Aug2015_v184.108.40.206.0), double-click on it to open the zip, and extract it to any directory using your preferred zip tool (WinRAR is shown):
Navigate to opa\bin in the expanded directory, e.g.Â OPA_Aug2015_v220.127.116.11.0\opa\bin
Double-click on the file install.cmd
This will open a DOS window where you will be prompted to answer a number of questions.
OPA runtime installer: Select option 3. (This will create a deployable war file)
Enter the deployment name: This can be any name, example opahub. This must consist of letters and underscores or hyphens only. Spaces are not permitted.
Database type: Select option 2 (This is the Oracle 11g database installed earlier)
Enter the Database connection server and port: localhost:1521
Enter Oracle TNS name: xe
Enter Datasource user: [This is the username noted down when the database was installed]
Enter Datasource password: [This is the password noted down when the database was installed]
OPA Encryption details: Hit enter to generate a key
Secure Session Cookie: Select option 1 (or just hit enter as this is the default)
Ready to Install: Hit enter
This completes this step of the deployment process. Note that we still need to deploy the web application to Tomcat to complete the installation.
Now, note down the encryption key generated. To do so, right-click on the DOS window, select Mark and highlight the key as shown above. Right-click again to copy the key (this is a silent operation – you will not see a menu). Now open a text editor e.g. Notepad, right-click and select Paste to paste in the key, and save the file with a meaningful name e.g. opa-encryption-key.txt
Step 5: Install the Hub Application
First, start the Oracle database from the start menu:
All Programs > Oracle Database 11g Express Edition > Start Database
A DOS window will appear.
After some time (up to a minute), you will see the message â€œThe OracleServiceXE service was started successfullyâ€ and you can then close the window.
If you donâ€™t see this message, stop the database and start again. Stop the Oracle database from the start menu:
All Programs > Oracle Database 11g Express Edition > Stop Database
(Note: this is also good practice when you are not using the OPA Hub, as it will conserve resources.)
Now we are ready to deploy the web applications we have just built. Navigate to opa\deploy\opahub in the OPA server component directory you unzipped earlier, e.g.
Enter the directory, which has the deployment name you selected during the Hub build process above. Within this are four files with a .war extension, whose name also starts with the deployment name. Highlight all the files by holding down shift, then right-click and select Copy (or CTRL+C).
Now, navigate to the directory where you unzipped Tomcat and open the directory webapps. Right-click and select Paste (or CTRL+V).
Navigate back up to the Tomcat directory, and select the directory bin. In this directory, double-click on startup.bat. This will open a DOS window with the Tomcat log.
You will reach a point where the window appears to hang. Once you have seen no activity for about 10 seconds, close the DOS window.
The reason it is hanging is because the Oracle database configuration set during the install is actually intended to configure Weblogic, whereas we are using the lightweight Tomcat container, for which the database connection information needs to be configured manually.
Navigate back to webapps in the Tomcat directory. You will observe that there are four new directories whose names correspond to the names of the .war files.
You will need to follow the step below for each of these three directories:
Open the directory, and within the directory open META-INF. Now open the file context.xml using an editing tool (e.g. Notepad or Notepad++). You may need to right-click and select Open With rather than double-clicking, since by default XML is associated with Internet Explorer. This is how the file will look:
Now delete the entire contents of this file, and replace it with the block of text below:
<?xml version=”1.0″ encoding=”UTF-8″?>
<!– context.xml is for tomcat deployment only –>
<Resource name=”hubDS” auth=”Container” type=”javax.sql.DataSource” maxActive=”100″ maxIdle=”30″ maxWait=”10000″ username=”alastair” password=”password” driverClassName=”oracle.jdbc.OracleDriver” url=”jdbc:oracle:thin:@localhost:1521:xe”/>
In the editor, replace â€œalastairâ€ with your username, and â€œpasswordâ€ with your password.
Save the file, replacing the previous context.xml.
Finally, it is necessary to rename one of the directories, since OPM 12 expects the name. Navigate back up to the Tomcat directory, and select webapps. Right-click on the directory
Select Rename (or click F2) and change the name to:
Your webapps directory should now look like this:
Step 6: Run the Hub application
Navigate to the Tomcat directory as before, and select the directory bin. In this directory, double-click on startup.bat. This will open a DOS window. Tomcat startup should now complete, and the message â€œServer startup in xxxx msâ€ will display at the bottom of the log in the DOS window.
You are now ready to log in to your new local Hub.
Open any browser, and enter the URL: http://localhost:8080/opa-hub
You will see a login screen asking for a username and password. The initial username is â€œadminâ€ and the password is â€œpasswordâ€.
Click Login, and you should now see the OPA Hub screen.
Step 7: Test the Hub
We will test the Hub with the common task Add Project to Repository. Open a project in Oracle Policy Modeling, and select this option. Now, complete the following details and click Add.
Now, return to your browser at http://localhost:8080/opa-hub and click on Repository. You should now see the project in the list of deployments:
Step 8: Use the Hub
In this tutorial we have installed a working local version of the Hub, which can be used offline, exactly as you would use the remote Hub. To start the Hub in future, follow the step Run the Hub Application.
The login / connection details will be:
When you have finished with the Hub and will not be using it for some time, it is good practice to close the Tomcat window and stop the Oracle database from the start menu:
All Programs > Oracle Database 11g Express Edition > Stop Database
Congratulations and thank you for following this tutorial. If you have any questions, please contact firstname.lastname@example.org