eclipse1

Setting up Eclipse for OPA Java Development

This article describes my favoured Eclipse set up to work with OPA web applications (ODS and OWD) in Java. I will describe a set up for OWD, but this can easily be adapted for ODS.

  1. Create a new Eclipse dynamic web project
  2. Select a target runtime, I am using Tomcat 7. If you don’t have one set up already then follow the usual Eclipse method of adding or installing a web runtime. And use 2.4 for the web module version.
  3. Locate your OPA Java runtime (downloaded from Oracle). Unzip the archive somewhere and locate the “web-determinations” directory. Expand the contained web-determinations.war using an unzip tool.
  4. I now re-use this expanded WAR across several projects that share the same OPA version. The next step is to link this directory into you web project.

  5. So your Eclipse project contents should look like this.
  6. Now we need to tell Eclipse to use the OWD war directory. Go to the project properties (alt-enter or right click on project and select properties). Go to the Deployment Assembly section and select Add and select the Folder directive.
  7. Select the expanded WAR directory this is now accessible via the folder linked into the Eclipse project
  8. The deployment assembly should now look like
  9. Depending on what you want to do you may decide to remove the Eclipse generated “WebContent” directory completely. However if you will be making any changes to the web context then it is useful to have a second web content directory as it acts as an overlay allowing you to override files in the out of the box web application without changing the original. However you will have to remove the additional web.xml at this point to allow things to work – so delete or rename the WebContent/WEB-INF/web.xml file.
  10. You can now run your Eclipse hosted OWD. Right click on the project and select Run As -> Run on Server. The console should start to show the Tomcat (in my case) start up logging and a browser window will open on the OWD home url.
  11. Now for some rulebases. If you are working on a specific rulebase then link it in whatever way suits you best. For this article I am going to expose all of the compiled rulebases that are supplied in the OPA Java Runtime.
  12. Go back to the project deployment dialog and add a new folder as below.
  13. Using the standard out of the box OWD configuration this directory should be mapped to the WEB-INF/classes/rulebases directory.
  14. Now restart the server and refresh the OWD url:
  15. You are now ready to go developing Java extensions, playing around with configuration files or Velocity templates. Some things to note.
  • Any resources that are present in the out of the box WEB-INF/classes directory can be overriden without changing the originals by adding them into the project src directory,
    this includes Velocity templates and properties files found in OWD.
  • You can override web.xml settings by placing a copy appropriately in your project WebContent directory, and this can be used to add other public web resources also.