Article
· Feb 24, 2021 1m read

Workshop exercises: develop interoperability components in Java (PEX)

Hi Developers! 
Let me share with you some exercises from a workshop about developing interoperability components in Java using PEX (Production EXtension).

You will find slides and step by step exercises about:

  • Understanding simple PEX components coded in Java.
  • Making some changes on them.

All built using containers, so you don't need to build a local Java environment.

You can reach the repository here:
https://openexchange.intersystems.com/package/workshop-pex

Discussion (6)2
Log in or sign up to continue

bash-3.2$ docker login

Authenticating with existing credentials...

Login Succeeded

bash-3.2$ docker-compose build

Building jgw

Step 1/9 : FROM openjdk:8 AS builder

---> 9324460525ca

Step 2/9 : ARG APP_HOME=/tmp/app

---> Using cache

---> 89bfa3325c80

Step 3/9 : COPY src $APP_HOME/src

---> Using cache

---> 34b6e7d671c2

Step 4/9 : COPY --from=intersystemscommunity/jgw:latest /jgw/*.jar $APP_HOME/jgw/

ERROR: Service 'jgw' failed to build: invalid from flag value intersystemscommunity/jgw:latest: pull access denied for intersystemscommunity/jgw, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

bash-3.2$

Seems like 'intersystemscommunity/jgw' is not available anymore. 

Hi @Eduard Lebedyuk / @Alberto Fuentes,

I am trying to use PEX / Java without docker.

So i have a jar containing the FirstOperation class and its all dependencies.

When i configure the object gateway and uses the same it never identifies the JAVA class.

Gives error as below,

Terminating Job 95839 / 'FirstOperation' with Status = ERROR #8104: Gateway Exception: <GATEWAY> java.lang.ClassNotFoundException java.net.URLClassLoader.findClass(URLClassLoader.java:382) workshop.pex.FirstOperation, %QuitTask=

Can you please guide me on, how do it use pex without docker. Why the class Loader can't find the java class within the jar?

I'll really be grateful to you, and wait for your response.

Regards,

Tirthankar

Hi Tirthankar,
You probably need to set up the Object Gateway classpath correctly.

I've just got it working as follows:

  1. Get the proper .jar files

I've copied them from the jgw container:

docker cp jgw:/jgw/FirstDemo.jar shared/ 
docker cp jgw:/jgw/gson-2.8.5.jar shared/     
docker cp jgw:/jgw/intersystems-gateway-3.1.0.jar shared/
docker cp jgw:/jgw/intersystems-jdbc-3.1.0.jar shared/    
docker cp jgw:/jgw/intersystems-utils-3.1.0.jar shared/

You can also generate your .jar files, just make sure it contains all the required dependencies.

  1. Set up your local Object Gateway:
  • IP address: 127.0.0.1
  • Port: 4444
  • ClassPath: /shared/FirstDemo.jar:/shared/gson-2.8.5.jar:/shared/intersystems-utils-3.1.0.jar

After that, start your Object Gateway, you should see something like:
Executing O.S. command: java -Xrs -classpath /shared/FirstDemo.jar:/shared/gson-2.8.5.jar:/shared/intersystems-utils-3.1.0.jar:/usr/irissys/dev/java/lib/JDK18/intersystems-gateway-3.1.0.jar:/usr/irissys/dev/java/lib/JDK18/intersystems-jdbc-3.1.0.jar com.intersystems.gateway.JavaGateway 4444 "" "" 127.0.0.1 ""

  1. Modify some of the PEX components in the production, e.g. FirstOperation:
  • Gateway Host: localhost
  • Gateway Port: 4444

That should work.