Skip to content

Using Reach from a FAT JAR

Enrique Noriega edited this page Jan 27, 2021 · 26 revisions

Reach Configuration

NOTE: Reach must be minimally configured to specify where to find input files for processing.

Input and output directories, and many other configuration options, are specified in the application.conf configuration file. For more information on configuring Reach see Step 2 on the Running Reach Wiki page.

Creating a FAT JAR

Reach can be compiled, along with all its required dependencies, into a single JVM JAR file, known as a 'FAT' JAR. To produce a default FAT JAR for Reach:

sbt assembly

The resulting FAT JAR will be located in the target/scala-2.12 subdirectory and will be named with the current project version number (1.X.Y) and the suffix -FAT.jar (e.g., reach-1.X.Y-SNAPSHOT-FAT.jar)

The default Reach FAT JAR runs a main program to do 'batch' mode processing: reading papers from an input directory and producing result files into an output directory. This is equivalent to running the main program org.clulab.reach.RunReachCLI using sbt.

A FAT JAR may also be produced which runs a different main program. For instance, to produce a FAT JAR which runs the interactive Reach Shell, compile it like this:

sbt -DmainClass=org.clulab.reach.ReachShell assembly

As mentioned, compiling a FAT JAR with no mainClass specification produces a FAT JAR which will run the batch mode program. The creation of such a FAT JAR file could (redundantly) also be specified like this:

sbt -DmainClass=org.clulab.reach.RunReachCLI assembly

Running the FAT JAR

Starting Reach from the FAT JAR

After starting the Server, run Reach from the same FAT JAR, again using the Java runtime system:

java -jar reach-1.X.Y-SNAPSHOT-FAT.jar

This command will default to using whichever mainClass you specified when you compiled the FAT JAR (as previously described above). Additional runtime arguments to the embedded main program may be provided on the command line after the JAR name.

Internal Web Service

As an alternative to batch mode, it is possible to create a FAT JAR which runs a small web service to process files via HTTP requests.

NOTE: Do not confuse this internal web service with the separate Server process which Reach now requires to run.

To create a FAT JAR which runs the web service, compile the FAT JAR like this:

sbt -DmainClass=org.clulab.reach.export.server.ApiServer assembly

To run the web service from the previously compiled FAT JAR, start the web service, as follows:

java -jar reach-1.X.Y-SNAPSHOT-FAT.jar

By default, the web service will run on port 8080 on the localhost. An alternative port may be specified with an additional argument as follows:

java -jar reach-1.X.Y-SNAPSHOT-FAT.jar --port 8088