You write rules, compile it, generate xgen files, package all this to rulebase.zip file. Now normally when you select ‘Run with oracle web determinations’ what happens is this rule base is deployed into the embedded tomcat web determinations server. You will be seeing a URL of pattern “http://localhost:9000/web-determinations9000/….” where the rulebase is locally hosted. Now if you want to host your rulebase in some other server which runs apache tomcat its very simple. You need to generate the war file with the rulebase.zip and deploy it. Let’s see how to prepare and package war file for the server deployment.
Deploy OPA Rulebase to Apache Tomcat Server
First create a test project whose rulebase is to be deployed. I have already shared the post on how to create a example rulebase using Oracle Policy Modeling please read if you want step by step explanation. If you already know working with Oracle Policy Modeling let’s continue with the rest of the step.
Create a new project in OPM and name it as “TomcatServer_Demo”.
Add a new word rule document named “rules.doc”. Open it and write the rule as shown in the image below.
the tutorial is complete if the rule base is in tomcat server
compile the rule and switch back to the OPM tool. Go to Build –> Build and Run –> Run with Oracle Web Determinations. Your browser will open a screen like this.
Now the URL is localhost:9000 which is the embedded server. Now, we are going to create the package war file that is to be deployed in the apache tomcat.
Packaging Rulebase war file for server deployment
Here in my case, the project “TomcatServer_Demo” is located in C:/projects. I need to get the rulebase.zip file from the Release folder. Here the file will be TomcatServer_Demo.zip which has the compiled rules.
Go to C:\projects\TomcatServer_Demo\Release\web-determinations\WEB-INF\classes\rulebases. This path may change if you have selected different location at the time of project creation. The structure path from ‘Release folder’ will be the same though. Get the TomcatServer_Demo.zip and copy it to desktop, don’t extract just copy.
Now go to the web-determination war file. Follow the Oracle Policy Modeling installation path. In my case the path was like;
C:\Program Files (x86)\Oracle\Policy Modeling\templates\web-determinations\java
Copy this file to the desktop and rename it with the name of project. This is just an optional step. It will be good when final URL is out on server. It will show the name of the war file in the URL. I have changed the name to ‘TomcatServer_Demo’. Open the war file using winrar, dont extract the files,
Go to WEB-INF –> clases –> rulebases. It will be having only readme.txt file initially.
Now go to C:\projects\TomcatServer_Demo\Release\web-determinations\WEB-INF\classes\rulebases and click and drag the TomcatServer_Demo.zip to the Winrar window. If you have copied this zip to desktop you can even drag and drop the same thing also.
Now the rulebase is added inside the war file. See the right window.
Now go to the apache tomcat installation directory. In my system it is in C:\apache-tomcat-7.0.56. Go to webapps folder and copy the packaged TomcatServer_Demo.war file.
All you need to do is just start the tomcat server. To start go to C:\apache-tomcat-7.0.56\bin and double click on startup. The black screen with certain deployment commands will show and thats it. Your war file is deployed and is up in server.
Go to browser and type localhost:8080/TomcatServer_Demo/ and enter. Brower will show the web determinations screens.
When I was testing I was getting a screen like this;
‘An error occurred trying to process your request. This error has been logged and is available in the application logs. For support and assistance please contact firstname.lastname@example.org.’
This is because you have entered the url without the ‘/’. There will be some other reason but, if you have followed all the steps like I explained then this is one of the reason. Delete everything after ‘TomcatServer_Demo/’ press enter. The issue is fixed.
So, that’s all about tomcat server deployment of OPM rulebase. Feel free to ask any doubts if you have any. Thank you for reading.