Updated for ver 6.023, 2024-02-12

# Setup: Third-party libraries

If you follow Setup Option B, you will need to download a few third-party libraries before you can compile the Rule Game Server from source. During the build, these libraries will be packed into the WAR file.

- Apache OpenJPA: from OpenJPA Downloads. This is a library used by the Game Server to store data in the SQL server in an "object-oriented way". On our development host we have OpenJPA 3.1, and have it installed in `/opt/apache-openjpa-3.1.0`, with a sym link from `/opt/apache-openjpa`. You may choose to download a more recent version, or to install OpenJPA to a different location; if you do that, then, before compiling the Rule Game Server from source, you will need to modify as appropriate the following line in `build.xml`:

        <property name="openjpa"  location="/opt/apache-openjpa"/>

- Apache Commons Math: The Commons Math: The Apache Commons Mathematics Library. (The build file refers to commons-math3-3.6.1, but you can update it to refer to the current version). If you're using Maven instead of Ant, you can also find it at https://mvnrepository.com/artifact/org.apache.commons/commons-math3/3.6.1 . Once downloaded, unzip it under `~/w2020`, and symlink it to commons-math3. This is how it all may look like:

       $  cd w2020/
       $  unzip ~/sys/commons-math3-3.6.1-bin.zip
       $  ln -s commons-math3-3.6.1/ commons-math3
       $  ls -l
      ....
      lrwxrwxrwx  1 vmenkov domain users   20 Jul 28 13:13 commons-math3 -> commons-math3-3.6.1/
      drwxr-xr-x  3 vmenkov domain users 4096 Mar 17  2016 commons-math3-3.6.1

- The JAX-RS RI bundle. It is used for working with JSON-format data, in particular for the REST interface of the Game Server. This is how:
  - You can download a file such as jaxrs-ri-2.31.zip, or (preferred!) a more recent version (such as 3.1.3). (To do that, you can start from e.g. https://mvnrepository.com/artifact/org.glassfish.jersey.bundles/jaxrs-ri -Jersey Bundles JAXRS RI , clicking on a version number such as `3.1.0-M2`, and then, in a page such as https://mvnrepository.com/artifact/org.glassfish.jersey.bundles/jaxrs-ri/3.1.0-M2 , clicking on `View all`, you get to a directory listing such as org/glassfish/jersey/bundles/jaxrs-ri/3.1.0-M2. In that page, you choose a ZIP file, such as `jaxrs-ri-3.1.0-M2.zip`).
  - Unpack it on your machine under `~/w2020`:

        	$  cd ~/w2020
        	$  unzip jaxrs-ri-3.1.0-M2.zip

    This will create the directory `~/w2020/jaxrs-ri`, with the JAX-RS stuff in it.
  NOTE: if you are using Tomcat 10.1 or above, it is strongly recommended that you download and use jaxrs-ri-3.1.3 or above. This is due to a compatibility issue with the servlet API library: an older version of jaxrs-ri may use a method (e.g. HttpServletRequest.setStatus(int,String)) which has been not just deprecated, but fully removed from the version of servlet-api.jar shipped with Tomcat starting with Tomcat 10.1.
- JAXB-RI, the XML binding library. To download it, one can start with https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-ri, choose a recent version (e.g. 3.0.2), then "View all", and finally download a file such as `jaxb-ri-3.0.2.zip`. Unpack the downloaded ZIP file on your machine under `~/w2020`:

      	cd ~/w2020
      	unzip jaxb-ri-3.0.2.zip

  This will create the directory `~/w2020/jaxb-ri`, with the JAXB-RI stuff in it.
- Jersey Media Multipart library. Download it from https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-multipart. Pick a recent version such as 3.0.4, which will take you to a pagae such as https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-multipart/3.0.4 ; there, click on `View all`, and download a file such as `jersey-media-multipart-3.0.4.jar`. Put it into the directory `~/w2020/other-lib`
- MIME Streaming Extension, e.g. `mimepull-1.9.14.jar`, from https://mvnrepository.com/artifact/org.jvnet.mimepull/mimepull/1.9.14. Put it into the directory `~/w2020/other-lib` as well.
- MySQL connector There is one more JAR file, needed to provide for connectivity between the Java applications (such as the Game Server) and your relational database. (If you don't, you will have a runtime error mentioning `com.mysql.cj.jdbc.Driver` when you try to use the Game Server).

  Prior to ver. 6.023, we would put that file into the Tomcat's lib directory; but on Plesk systems, this is not recommended, therefore now we place it into `~/w2020/other-lib` as well, so that it gets packed into the application WAR file along with all other JAR files.

  (The historic reason while it was handled in that special way was that we wanted Tomcat's own authentication system to access the MySQL server, where passwords etc would be stored. But that was given up early on).

  If your database server is the MySQL server, then the necessary JAR file can be downloaded from the Connector/J site. At that site, choose the appropriate version for your OS.

  On our system, we have put that JAR file into `/opt/w2020/lib` (earlier, in `/usr/share/java`), and sym-linked it to w2020/other-lib.

          cd
          cd w2020/other-lib
          sudo ln -s /opt/w2020/lib/mysql-connector-java-8.0.20.jar

  As of 2023, the above web site offers you downloading in the form a *.deb file, e.g. mysql-connector-j_8.1.0-1ubuntu22.04_all.deb . Once downloaded, you can install it with

            dpkg -i mysql-connector-j_8.1.0-1ubuntu22.04_all.deb

  To find out what files you have actually downloaded by doing this, try

      $ dpkg-deb -c mysql-connector-j_8.1.0-1ubuntu22.04_all.deb
      drwxr-xr-x root/root         0 2023-06-26 12:10 ./
      drwxr-xr-x root/root         0 2023-06-26 12:10 ./usr/
      drwxr-xr-x root/root         0 2023-06-26 12:10 ./usr/share/
      drwxr-xr-x root/root         0 2023-06-26 12:10 ./usr/share/doc/
      ...
      drwxr-xr-x root/root         0 2023-06-26 12:10 ./usr/share/java/
      -rw-r--r-- root/root   2485886 2023-06-26 12:10 ./usr/share/java/mysql-connector-j-8.1.0.jar
      lrwxrwxrwx root/root         0 2023-06-26 12:10 ./usr/share/java/mysql-connector-java-8.1.0.jar -> mysql-connector-j-8.1.0.jar

  So this tells you where the JAR file gets installed, and you can simply sym-link it into `w2020/other-lib` directory, instead of copying it.